diff --git a/.release-please-manifest.json b/.release-please-manifest.json index e7562934..0c2ecec6 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "0.19.0" + ".": "0.20.0" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index c16b34ce..6c745f0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,33 @@ # Changelog +## 0.20.0 (2025-01-07) + +Full Changelog: [v0.19.0...v0.20.0](https://github.com/orbcorp/orb-java/compare/v0.19.0...v0.20.0) + +### Features + +* **client:** add various convenience setters to models ([#184](https://github.com/orbcorp/orb-java/issues/184)) ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) +* **client:** allow setting arbitrary JSON for top-level body params ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) +* **client:** expose getters for `JsonField` of body params ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) + + +### Bug Fixes + +* **client:** consistently throw on omitting required fields ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) +* **client:** convert `JsonField` containing list type to mutable in builder ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) + + +### Documentation + +* add params class javadocs ([#182](https://github.com/orbcorp/orb-java/issues/182)) ([e98658d](https://github.com/orbcorp/orb-java/commit/e98658d54e9ef45334ae98fe2901a2db1574a900)) + + +### Styles + +* **internal:** explicitly add some method return types ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) +* **internal:** move headers and query params setters below others ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) +* **internal:** simplify existing convenience setters on params ([5a7e67f](https://github.com/orbcorp/orb-java/commit/5a7e67f4aff5cd005c04148c72c4f9dbb1f65449)) + ## 0.19.0 (2025-01-06) Full Changelog: [v0.18.0...v0.19.0](https://github.com/orbcorp/orb-java/compare/v0.18.0...v0.19.0) diff --git a/README.md b/README.md index 6654207a..f98dc8ea 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ -[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.19.0) +[![Maven Central](https://img.shields.io/maven-central/v/com.withorb.api/orb-java)](https://central.sonatype.com/artifact/com.withorb.api/orb-java/0.20.0) @@ -25,7 +25,7 @@ The REST API documentation can be foundĀ on [docs.withorb.com](https://docs.with ```kotlin -implementation("com.withorb.api:orb-java:0.19.0") +implementation("com.withorb.api:orb-java:0.20.0") ``` #### Maven @@ -34,7 +34,7 @@ implementation("com.withorb.api:orb-java:0.19.0") com.withorb.api orb-java - 0.19.0 + 0.20.0 ``` diff --git a/build.gradle.kts b/build.gradle.kts index 64a0a083..2cba1d15 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { allprojects { group = "com.withorb.api" - version = "0.19.0" // x-release-please-version + version = "0.20.0" // x-release-please-version } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt index 39bcc89e..13987e4d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/core/ClientOptions.kt @@ -72,6 +72,19 @@ private constructor( fun baseUrl(baseUrl: String) = apply { this.baseUrl = baseUrl } + fun responseValidation(responseValidation: Boolean) = apply { + this.responseValidation = responseValidation + } + + fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } + + fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } + + fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } + + fun webhookSecret(webhookSecret: Optional) = + webhookSecret(webhookSecret.orElse(null)) + fun headers(headers: Headers) = apply { this.headers.clear() putAllHeaders(headers) @@ -152,19 +165,6 @@ private constructor( fun removeAllQueryParams(keys: Set) = apply { queryParams.removeAll(keys) } - fun responseValidation(responseValidation: Boolean) = apply { - this.responseValidation = responseValidation - } - - fun maxRetries(maxRetries: Int) = apply { this.maxRetries = maxRetries } - - fun apiKey(apiKey: String) = apply { this.apiKey = apiKey } - - fun webhookSecret(webhookSecret: String?) = apply { this.webhookSecret = webhookSecret } - - fun webhookSecret(webhookSecret: Optional) = - webhookSecret(webhookSecret.orElse(null)) - fun fromEnv() = apply { System.getenv("ORB_API_KEY")?.let { apiKey(it) } System.getenv("ORB_WEBHOOK_SECRET")?.let { webhookSecret(it) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt index 04d2bcbd..9f81d149 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Alert.kt @@ -89,34 +89,40 @@ private constructor( fun type(): Type = type.getRequired("type") /** Also referred to as alert_id in this documentation. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The creation time of the resource in Orb. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** The name of the currency the credit balance or invoice cost is denominated in. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The customer the alert applies to. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** Whether the alert is enabled or disabled. */ - @JsonProperty("enabled") @ExcludeMissing fun _enabled() = enabled + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled /** The metric the alert applies to. */ - @JsonProperty("metric") @ExcludeMissing fun _metric() = metric + @JsonProperty("metric") @ExcludeMissing fun _metric(): JsonField = metric /** The plan the alert applies to. */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The subscription the alert applies to. */ - @JsonProperty("subscription") @ExcludeMissing fun _subscription() = subscription + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription /** The thresholds that define the conditions under which the alert will be triggered. */ - @JsonProperty("thresholds") @ExcludeMissing fun _thresholds() = thresholds + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds /** The type of alert. This must be a valid alert type. */ - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -149,16 +155,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var enabled: JsonField = JsonMissing.of() - private var metric: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var subscription: JsonField = JsonMissing.of() - private var thresholds: JsonField> = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var enabled: JsonField? = null + private var metric: JsonField? = null + private var plan: JsonField? = null + private var subscription: JsonField? = null + private var thresholds: JsonField>? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -171,7 +177,7 @@ private constructor( metric = alert.metric plan = alert.plan subscription = alert.subscription - thresholds = alert.thresholds + thresholds = alert.thresholds.map { it.toMutableList() } type = alert.type additionalProperties = alert.additionalProperties.toMutableMap() } @@ -189,13 +195,19 @@ private constructor( fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } /** The name of the currency the credit balance or invoice cost is denominated in. */ - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + /** The name of the currency the credit balance or invoice cost is denominated in. */ + fun currency(currency: Optional) = currency(currency.orElse(null)) /** The name of the currency the credit balance or invoice cost is denominated in. */ fun currency(currency: JsonField) = apply { this.currency = currency } /** The customer the alert applies to. */ - fun customer(customer: Customer) = customer(JsonField.of(customer)) + fun customer(customer: Customer?) = customer(JsonField.ofNullable(customer)) + + /** The customer the alert applies to. */ + fun customer(customer: Optional) = customer(customer.orElse(null)) /** The customer the alert applies to. */ fun customer(customer: JsonField) = apply { this.customer = customer } @@ -207,19 +219,30 @@ private constructor( fun enabled(enabled: JsonField) = apply { this.enabled = enabled } /** The metric the alert applies to. */ - fun metric(metric: Metric) = metric(JsonField.of(metric)) + fun metric(metric: Metric?) = metric(JsonField.ofNullable(metric)) + + /** The metric the alert applies to. */ + fun metric(metric: Optional) = metric(metric.orElse(null)) /** The metric the alert applies to. */ fun metric(metric: JsonField) = apply { this.metric = metric } /** The plan the alert applies to. */ - fun plan(plan: Plan) = plan(JsonField.of(plan)) + fun plan(plan: Plan?) = plan(JsonField.ofNullable(plan)) + + /** The plan the alert applies to. */ + fun plan(plan: Optional) = plan(plan.orElse(null)) /** The plan the alert applies to. */ fun plan(plan: JsonField) = apply { this.plan = plan } /** The subscription the alert applies to. */ - fun subscription(subscription: Subscription) = subscription(JsonField.of(subscription)) + fun subscription(subscription: Subscription?) = + subscription(JsonField.ofNullable(subscription)) + + /** The subscription the alert applies to. */ + fun subscription(subscription: Optional) = + subscription(subscription.orElse(null)) /** The subscription the alert applies to. */ fun subscription(subscription: JsonField) = apply { @@ -227,11 +250,28 @@ private constructor( } /** The thresholds that define the conditions under which the alert will be triggered. */ - fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + fun thresholds(thresholds: List?) = thresholds(JsonField.ofNullable(thresholds)) + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) /** The thresholds that define the conditions under which the alert will be triggered. */ fun thresholds(thresholds: JsonField>) = apply { - this.thresholds = thresholds + this.thresholds = thresholds.map { it.toMutableList() } + } + + /** The thresholds that define the conditions under which the alert will be triggered. */ + fun addThreshold(threshold: Threshold) = apply { + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(threshold) + } } /** The type of alert. This must be a valid alert type. */ @@ -261,16 +301,17 @@ private constructor( fun build(): Alert = Alert( - id, - createdAt, - currency, - customer, - enabled, - metric, - plan, - subscription, - thresholds.map { it.toImmutable() }, - type, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(enabled) { "`enabled` is required but was not set" }, + checkNotNull(metric) { "`metric` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(subscription) { "`subscription` is required but was not set" }, + checkNotNull(thresholds) { "`thresholds` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -293,11 +334,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -322,8 +363,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -337,8 +378,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -365,8 +409,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -401,7 +447,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -425,7 +471,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -457,7 +503,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Metric = Metric(id, additionalProperties.toImmutable()) + fun build(): Metric = + Metric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -510,18 +560,22 @@ private constructor( fun planVersion(): String = planVersion.getRequired("plan_version") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your * system. */ - @JsonProperty("external_plan_id") @ExcludeMissing fun _externalPlanId() = externalPlanId + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_version") @ExcludeMissing fun _planVersion() = planVersion + @JsonProperty("plan_version") + @ExcludeMissing + fun _planVersion(): JsonField = planVersion @JsonAnyGetter @ExcludeMissing @@ -548,10 +602,10 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalPlanId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planVersion: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null + private var planVersion: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -563,7 +617,9 @@ private constructor( additionalProperties = plan.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun id(id: String?) = id(JsonField.ofNullable(id)) + + fun id(id: Optional) = id(id.orElse(null)) fun id(id: JsonField) = apply { this.id = id } @@ -572,8 +628,16 @@ private constructor( * alias for this Plan. Use this field to identify a plan by an existing identifier in * your system. */ - fun externalPlanId(externalPlanId: String) = - externalPlanId(JsonField.of(externalPlanId)) + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -584,7 +648,9 @@ private constructor( this.externalPlanId = externalPlanId } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) fun name(name: JsonField) = apply { this.name = name } @@ -615,10 +681,10 @@ private constructor( fun build(): Plan = Plan( - id, - externalPlanId, - name, - planVersion, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalPlanId) { "`externalPlanId` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planVersion) { "`planVersion` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -653,7 +719,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -677,7 +743,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -709,7 +775,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Subscription = Subscription(id, additionalProperties.toImmutable()) + fun build(): Subscription = + Subscription( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -753,7 +823,7 @@ private constructor( * or below this value. For usage and cost alerts, the alert will fire at or above this * value. */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -777,7 +847,7 @@ private constructor( class Builder { - private var value: JsonField = JsonMissing.of() + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -819,7 +889,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Threshold = Threshold(value, additionalProperties.toImmutable()) + fun build(): Threshold = + Threshold( + checkNotNull(value) { "`value` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt index 1e152e87..1cac4a23 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForCustomerParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,14 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** + * This endpoint creates a new alert to monitor a customer's credit balance. There are three types + * of alerts that can be scoped to customers: `credit_balance_depleted`, `credit_balance_dropped`, + * and `credit_balance_recovered`. Customers can have a maximum of one of each type of alert per + * [credit balance currency](https://docs.withorb.com/guides/product-catalog/prepurchase). + * `credit_balance_dropped` alerts require a list of thresholds to be provided while + * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. + */ class AlertCreateForCustomerParams constructor( private val customerId: String, @@ -38,12 +47,21 @@ constructor( /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(): Optional> = body.thresholds() - fun _additionalHeaders(): Headers = additionalHeaders + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun _currency(): JsonField = body._currency() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The type of alert to create. This must be a valid alert type. */ + fun _type(): JsonField = body._type() + + /** The thresholds that define the values at which the alert will be triggered. */ + fun _thresholds(): JsonField> = body._thresholds() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): AlertCreateForCustomerBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -61,27 +79,53 @@ constructor( class AlertCreateForCustomerBody @JsonCreator internal constructor( - @JsonProperty("currency") private val currency: String, - @JsonProperty("type") private val type: Type, - @JsonProperty("thresholds") private val thresholds: List?, + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + private val thresholds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The case sensitive currency or custom pricing unit to use for this alert. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") + + /** The type of alert to create. This must be a valid alert type. */ + fun type(): Type = type.getRequired("type") + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(): Optional> = + Optional.ofNullable(thresholds.getNullable("thresholds")) + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The type of alert to create. This must be a valid alert type. */ - @JsonProperty("type") fun type(): Type = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The thresholds that define the values at which the alert will be triggered. */ @JsonProperty("thresholds") - fun thresholds(): Optional> = Optional.ofNullable(thresholds) + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AlertCreateForCustomerBody = apply { + if (!validated) { + currency() + type() + thresholds().map { it.forEach { it.validate() } } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -91,38 +135,57 @@ constructor( class Builder { - private var currency: String? = null - private var type: Type? = null - private var thresholds: MutableList? = null + private var currency: JsonField? = null + private var type: JsonField? = null + private var thresholds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(alertCreateForCustomerBody: AlertCreateForCustomerBody) = apply { currency = alertCreateForCustomerBody.currency type = alertCreateForCustomerBody.type - thresholds = alertCreateForCustomerBody.thresholds?.toMutableList() + thresholds = alertCreateForCustomerBody.thresholds.map { it.toMutableList() } additionalProperties = alertCreateForCustomerBody.additionalProperties.toMutableMap() } /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: Type) = type(JsonField.of(type)) /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List?) = apply { - this.thresholds = thresholds?.toMutableList() - } + fun thresholds(thresholds: List?) = + thresholds(JsonField.ofNullable(thresholds)) /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { - thresholds = (thresholds ?: mutableListOf()).apply { add(threshold) } + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(threshold) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -148,7 +211,7 @@ constructor( AlertCreateForCustomerBody( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, - thresholds?.toImmutable(), + (thresholds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -199,18 +262,48 @@ constructor( /** The case sensitive currency or custom pricing unit to use for this alert. */ fun currency(currency: String) = apply { body.currency(currency) } + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** The type of alert to create. This must be a valid alert type. */ fun type(type: Type) = apply { body.type(type) } + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: JsonField) = apply { body.type(type) } + /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: List?) = apply { body.thresholds(thresholds) } /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + body.thresholds(thresholds) + } + /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -309,25 +402,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): AlertCreateForCustomerParams = AlertCreateForCustomerParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, @@ -417,7 +491,9 @@ constructor( class Threshold @JsonCreator private constructor( - @JsonProperty("value") private val value: Double, + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -427,12 +503,28 @@ constructor( * or below this value. For usage and cost alerts, the alert will fire at or above this * value. */ - @JsonProperty("value") fun value(): Double = value + fun value(): Double = value.getRequired("value") + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at + * or below this value. For usage and cost alerts, the alert will fire at or above this + * value. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Threshold = apply { + if (!validated) { + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -442,7 +534,7 @@ constructor( class Builder { - private var value: Double? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -456,7 +548,14 @@ constructor( * at or below this value. For usage and cost alerts, the alert will fire at or above * this value. */ - fun value(value: Double) = apply { this.value = value } + fun value(value: Double) = value(JsonField.of(value)) + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire + * at or below this value. For usage and cost alerts, the alert will fire at or above + * this value. + */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt index 5c144763..37f68a25 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForExternalCustomerParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,14 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** + * This endpoint creates a new alert to monitor a customer's credit balance. There are three types + * of alerts that can be scoped to customers: `credit_balance_depleted`, `credit_balance_dropped`, + * and `credit_balance_recovered`. Customers can have a maximum of one of each type of alert per + * [credit balance currency](https://docs.withorb.com/guides/product-catalog/prepurchase). + * `credit_balance_dropped` alerts require a list of thresholds to be provided while + * `credit_balance_depleted` and `credit_balance_recovered` alerts do not require thresholds. + */ class AlertCreateForExternalCustomerParams constructor( private val externalCustomerId: String, @@ -38,12 +47,21 @@ constructor( /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(): Optional> = body.thresholds() - fun _additionalHeaders(): Headers = additionalHeaders + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun _currency(): JsonField = body._currency() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The type of alert to create. This must be a valid alert type. */ + fun _type(): JsonField = body._type() + + /** The thresholds that define the values at which the alert will be triggered. */ + fun _thresholds(): JsonField> = body._thresholds() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): AlertCreateForExternalCustomerBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -61,27 +79,53 @@ constructor( class AlertCreateForExternalCustomerBody @JsonCreator internal constructor( - @JsonProperty("currency") private val currency: String, - @JsonProperty("type") private val type: Type, - @JsonProperty("thresholds") private val thresholds: List?, + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("thresholds") + @ExcludeMissing + private val thresholds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The case sensitive currency or custom pricing unit to use for this alert. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") + + /** The type of alert to create. This must be a valid alert type. */ + fun type(): Type = type.getRequired("type") + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(): Optional> = + Optional.ofNullable(thresholds.getNullable("thresholds")) + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The type of alert to create. This must be a valid alert type. */ - @JsonProperty("type") fun type(): Type = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The thresholds that define the values at which the alert will be triggered. */ @JsonProperty("thresholds") - fun thresholds(): Optional> = Optional.ofNullable(thresholds) + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AlertCreateForExternalCustomerBody = apply { + if (!validated) { + currency() + type() + thresholds().map { it.forEach { it.validate() } } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -91,9 +135,9 @@ constructor( class Builder { - private var currency: String? = null - private var type: Type? = null - private var thresholds: MutableList? = null + private var currency: JsonField? = null + private var type: JsonField? = null + private var thresholds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -102,29 +146,49 @@ constructor( ) = apply { currency = alertCreateForExternalCustomerBody.currency type = alertCreateForExternalCustomerBody.type - thresholds = alertCreateForExternalCustomerBody.thresholds?.toMutableList() + thresholds = + alertCreateForExternalCustomerBody.thresholds.map { it.toMutableList() } additionalProperties = alertCreateForExternalCustomerBody.additionalProperties.toMutableMap() } /** The case sensitive currency or custom pricing unit to use for this alert. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: Type) = type(JsonField.of(type)) /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List?) = apply { - this.thresholds = thresholds?.toMutableList() - } + fun thresholds(thresholds: List?) = + thresholds(JsonField.ofNullable(thresholds)) /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } + } + /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { - thresholds = (thresholds ?: mutableListOf()).apply { add(threshold) } + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(threshold) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -150,7 +214,7 @@ constructor( AlertCreateForExternalCustomerBody( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(type) { "`type` is required but was not set" }, - thresholds?.toImmutable(), + (thresholds ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -207,18 +271,48 @@ constructor( /** The case sensitive currency or custom pricing unit to use for this alert. */ fun currency(currency: String) = apply { body.currency(currency) } + /** The case sensitive currency or custom pricing unit to use for this alert. */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** The type of alert to create. This must be a valid alert type. */ fun type(type: Type) = apply { body.type(type) } + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: JsonField) = apply { body.type(type) } + /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: List?) = apply { body.thresholds(thresholds) } /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: Optional>) = thresholds(thresholds.orElse(null)) + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + body.thresholds(thresholds) + } + /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -317,25 +411,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): AlertCreateForExternalCustomerParams = AlertCreateForExternalCustomerParams( checkNotNull(externalCustomerId) { @@ -427,7 +502,9 @@ constructor( class Threshold @JsonCreator private constructor( - @JsonProperty("value") private val value: Double, + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -437,12 +514,28 @@ constructor( * or below this value. For usage and cost alerts, the alert will fire at or above this * value. */ - @JsonProperty("value") fun value(): Double = value + fun value(): Double = value.getRequired("value") + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at + * or below this value. For usage and cost alerts, the alert will fire at or above this + * value. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Threshold = apply { + if (!validated) { + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -452,7 +545,7 @@ constructor( class Builder { - private var value: Double? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -466,7 +559,14 @@ constructor( * at or below this value. For usage and cost alerts, the alert will fire at or above * this value. */ - fun value(value: Double) = apply { this.value = value } + fun value(value: Double) = value(JsonField.of(value)) + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire + * at or below this value. For usage and cost alerts, the alert will fire at or above + * this value. + */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt index daa10ea4..373e5d47 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertCreateForSubscriptionParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,18 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** + * This endpoint is used to create alerts at the subscription level. + * + * Subscription level alerts can be one of two types: `usage_exceeded` or `cost_exceeded`. A + * `usage_exceeded` alert is scoped to a particular metric and is triggered when the usage of that + * metric exceeds predefined thresholds during the current billing cycle. A `cost_exceeded` alert is + * triggered when the total amount due during the current billing cycle surpasses predefined + * thresholds. `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each + * subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert per metric that is + * a part of the subscription. Alerts are triggered based on usage or cost conditions met during the + * current billing cycle. + */ class AlertCreateForSubscriptionParams constructor( private val subscriptionId: String, @@ -38,12 +51,21 @@ constructor( /** The metric to track usage for. */ fun metricId(): Optional = body.metricId() - fun _additionalHeaders(): Headers = additionalHeaders + /** The thresholds that define the values at which the alert will be triggered. */ + fun _thresholds(): JsonField> = body._thresholds() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The type of alert to create. This must be a valid alert type. */ + fun _type(): JsonField = body._type() + + /** The metric to track usage for. */ + fun _metricId(): JsonField = body._metricId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): AlertCreateForSubscriptionBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -61,26 +83,52 @@ constructor( class AlertCreateForSubscriptionBody @JsonCreator internal constructor( - @JsonProperty("thresholds") private val thresholds: List, - @JsonProperty("type") private val type: Type, - @JsonProperty("metric_id") private val metricId: String?, + @JsonProperty("thresholds") + @ExcludeMissing + private val thresholds: JsonField> = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("metric_id") + @ExcludeMissing + private val metricId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The thresholds that define the values at which the alert will be triggered. */ - @JsonProperty("thresholds") fun thresholds(): List = thresholds + fun thresholds(): List = thresholds.getRequired("thresholds") /** The type of alert to create. This must be a valid alert type. */ - @JsonProperty("type") fun type(): Type = type + fun type(): Type = type.getRequired("type") /** The metric to track usage for. */ - @JsonProperty("metric_id") fun metricId(): Optional = Optional.ofNullable(metricId) + fun metricId(): Optional = Optional.ofNullable(metricId.getNullable("metric_id")) + + /** The thresholds that define the values at which the alert will be triggered. */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds + + /** The type of alert to create. This must be a valid alert type. */ + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + /** The metric to track usage for. */ + @JsonProperty("metric_id") @ExcludeMissing fun _metricId(): JsonField = metricId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AlertCreateForSubscriptionBody = apply { + if (!validated) { + thresholds().forEach { it.validate() } + type() + metricId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -90,15 +138,16 @@ constructor( class Builder { - private var thresholds: MutableList? = null - private var type: Type? = null - private var metricId: String? = null + private var thresholds: JsonField>? = null + private var type: JsonField? = null + private var metricId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(alertCreateForSubscriptionBody: AlertCreateForSubscriptionBody) = apply { - thresholds = alertCreateForSubscriptionBody.thresholds.toMutableList() + thresholds = + alertCreateForSubscriptionBody.thresholds.map { it.toMutableList() } type = alertCreateForSubscriptionBody.type metricId = alertCreateForSubscriptionBody.metricId additionalProperties = @@ -106,24 +155,42 @@ constructor( } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List) = apply { - this.thresholds = thresholds.toMutableList() + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } } /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { - thresholds = (thresholds ?: mutableListOf()).apply { add(threshold) } + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(threshold) + } } /** The type of alert to create. This must be a valid alert type. */ - fun type(type: Type) = apply { this.type = type } + fun type(type: Type) = type(JsonField.of(type)) + + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: JsonField) = apply { this.type = type } /** The metric to track usage for. */ - fun metricId(metricId: String?) = apply { this.metricId = metricId } + fun metricId(metricId: String?) = metricId(JsonField.ofNullable(metricId)) /** The metric to track usage for. */ fun metricId(metricId: Optional) = metricId(metricId.orElse(null)) + /** The metric to track usage for. */ + fun metricId(metricId: JsonField) = apply { this.metricId = metricId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -146,7 +213,7 @@ constructor( fun build(): AlertCreateForSubscriptionBody = AlertCreateForSubscriptionBody( checkNotNull(thresholds) { "`thresholds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(type) { "`type` is required but was not set" }, metricId, additionalProperties.toImmutable(), @@ -202,18 +269,48 @@ constructor( /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: List) = apply { body.thresholds(thresholds) } + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + body.thresholds(thresholds) + } + /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } /** The type of alert to create. This must be a valid alert type. */ fun type(type: Type) = apply { body.type(type) } + /** The type of alert to create. This must be a valid alert type. */ + fun type(type: JsonField) = apply { body.type(type) } + /** The metric to track usage for. */ fun metricId(metricId: String?) = apply { body.metricId(metricId) } /** The metric to track usage for. */ fun metricId(metricId: Optional) = metricId(metricId.orElse(null)) + /** The metric to track usage for. */ + fun metricId(metricId: JsonField) = apply { body.metricId(metricId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -312,25 +409,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): AlertCreateForSubscriptionParams = AlertCreateForSubscriptionParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, @@ -345,7 +423,9 @@ constructor( class Threshold @JsonCreator private constructor( - @JsonProperty("value") private val value: Double, + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -355,12 +435,28 @@ constructor( * or below this value. For usage and cost alerts, the alert will fire at or above this * value. */ - @JsonProperty("value") fun value(): Double = value + fun value(): Double = value.getRequired("value") + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at + * or below this value. For usage and cost alerts, the alert will fire at or above this + * value. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Threshold = apply { + if (!validated) { + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -370,7 +466,7 @@ constructor( class Builder { - private var value: Double? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -384,7 +480,14 @@ constructor( * at or below this value. For usage and cost alerts, the alert will fire at or above * this value. */ - fun value(value: Double) = apply { this.value = value } + fun value(value: Double) = value(JsonField.of(value)) + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire + * at or below this value. For usage and cost alerts, the alert will fire at or above + * this value. + */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt index bbe95c43..80085dd8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertDisableParams.kt @@ -10,6 +10,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to disable an alert. To disable a plan-level alert for a specific + * subscription, you must include the `subscription_id`. The `subscription_id` is not required for + * customer or subscription level alerts. + */ class AlertDisableParams constructor( private val alertConfigurationId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt index 2a91ab5b..fa7e1205 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertEnableParams.kt @@ -10,6 +10,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to enable an alert. To enable a plan-level alert for a specific + * subscription, you must include the `subscription_id`. The `subscription_id` is not required for + * customer or subscription level alerts. + */ class AlertEnableParams constructor( private val alertConfigurationId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt index 19de6751..2d10e511 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertListParams.kt @@ -10,6 +10,17 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of alerts within Orb. + * + * The request must specify one of `customer_id`, `external_customer_id`, or `subscription_id`. + * + * If querying by subscripion_id, the endpoint will return the subscription level alerts as well as + * the plan level alerts associated with the subscription. + * + * The list of alerts is ordered starting from the most recently created alert. This endpoint + * follows Orb's [standardized pagination format](../reference/pagination). + */ class AlertListParams constructor( private val createdAtGt: OffsetDateTime?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt index 24bbd18a..f81abfaf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertRetrieveParams.kt @@ -7,6 +7,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** This endpoint retrieves an alert by its ID. */ class AlertRetrieveParams constructor( private val alertId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt index 4ae8de06..cf14aeed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AlertUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -15,6 +17,7 @@ import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import java.util.Objects +/** This endpoint updates the thresholds of an alert. */ class AlertUpdateParams constructor( private val alertConfigurationId: String, @@ -28,12 +31,15 @@ constructor( /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(): List = body.thresholds() + /** The thresholds that define the values at which the alert will be triggered. */ + fun _thresholds(): JsonField> = body._thresholds() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): AlertUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -51,18 +57,34 @@ constructor( class AlertUpdateBody @JsonCreator internal constructor( - @JsonProperty("thresholds") private val thresholds: List, + @JsonProperty("thresholds") + @ExcludeMissing + private val thresholds: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The thresholds that define the values at which the alert will be triggered. */ - @JsonProperty("thresholds") fun thresholds(): List = thresholds + fun thresholds(): List = thresholds.getRequired("thresholds") + + /** The thresholds that define the values at which the alert will be triggered. */ + @JsonProperty("thresholds") + @ExcludeMissing + fun _thresholds(): JsonField> = thresholds @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AlertUpdateBody = apply { + if (!validated) { + thresholds().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,23 +94,35 @@ constructor( class Builder { - private var thresholds: MutableList? = null + private var thresholds: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(alertUpdateBody: AlertUpdateBody) = apply { - thresholds = alertUpdateBody.thresholds.toMutableList() + thresholds = alertUpdateBody.thresholds.map { it.toMutableList() } additionalProperties = alertUpdateBody.additionalProperties.toMutableMap() } /** The thresholds that define the values at which the alert will be triggered. */ - fun thresholds(thresholds: List) = apply { - this.thresholds = thresholds.toMutableList() + fun thresholds(thresholds: List) = thresholds(JsonField.of(thresholds)) + + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + this.thresholds = thresholds.map { it.toMutableList() } } /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { - thresholds = (thresholds ?: mutableListOf()).apply { add(threshold) } + thresholds = + (thresholds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(threshold) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -113,7 +147,7 @@ constructor( fun build(): AlertUpdateBody = AlertUpdateBody( checkNotNull(thresholds) { "`thresholds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -166,9 +200,33 @@ constructor( /** The thresholds that define the values at which the alert will be triggered. */ fun thresholds(thresholds: List) = apply { body.thresholds(thresholds) } + /** The thresholds that define the values at which the alert will be triggered. */ + fun thresholds(thresholds: JsonField>) = apply { + body.thresholds(thresholds) + } + /** The thresholds that define the values at which the alert will be triggered. */ fun addThreshold(threshold: Threshold) = apply { body.addThreshold(threshold) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -267,25 +325,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): AlertUpdateParams = AlertUpdateParams( checkNotNull(alertConfigurationId) { @@ -302,7 +341,9 @@ constructor( class Threshold @JsonCreator private constructor( - @JsonProperty("value") private val value: Double, + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -312,12 +353,28 @@ constructor( * or below this value. For usage and cost alerts, the alert will fire at or above this * value. */ - @JsonProperty("value") fun value(): Double = value + fun value(): Double = value.getRequired("value") + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire at + * or below this value. For usage and cost alerts, the alert will fire at or above this + * value. + */ + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Threshold = apply { + if (!validated) { + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -327,7 +384,7 @@ constructor( class Builder { - private var value: Double? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -341,7 +398,14 @@ constructor( * at or below this value. For usage and cost alerts, the alert will fire at or above * this value. */ - fun value(value: Double) = apply { this.value = value } + fun value(value: Double) = value(JsonField.of(value)) + + /** + * The value at which an alert will fire. For credit balance alerts, the alert will fire + * at or below this value. For usage and cost alerts, the alert will fire at or above + * this value. + */ + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt index 742a810c..4aff865f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/AmountDiscount.kt @@ -51,7 +51,9 @@ private constructor( fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** * List of price_ids that this discount applies to. For plan/plan phase discounts, this can be a @@ -59,11 +61,13 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -90,16 +94,16 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscount: AmountDiscount) = apply { this.amountDiscount = amountDiscount.amountDiscount - appliesToPriceIds = amountDiscount.appliesToPriceIds + appliesToPriceIds = amountDiscount.appliesToPriceIds.map { it.toMutableList() } discountType = amountDiscount.discountType reason = amountDiscount.reason additionalProperties = amountDiscount.additionalProperties.toMutableMap() @@ -125,7 +129,24 @@ private constructor( * be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -134,7 +155,9 @@ private constructor( this.discountType = discountType } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -159,9 +182,12 @@ private constructor( fun build(): AmountDiscount = AmountDiscount( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - discountType, + checkNotNull(amountDiscount) { "`amountDiscount` is required but was not set" }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, reason, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt index 78faf058..9cadf9c3 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/BillableMetric.kt @@ -64,27 +64,27 @@ private constructor( fun status(): Status = status.getRequired("status") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** * The Item resource represents a sellable product or good. Items are associated with all line * items, billable metrics, and prices and are used for defining external sync behavior for * invoices and tax calculation purposes. */ - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -113,12 +113,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var description: JsonField? = null + private var item: JsonField? = null + private var metadata: JsonField? = null + private var name: JsonField? = null + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -136,7 +136,9 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description } @@ -197,12 +199,12 @@ private constructor( fun build(): BillableMetric = BillableMetric( - id, - description, - item, - metadata, - name, - status, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt index 0dc97ab6..3ef0e60a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Coupon.kt @@ -125,33 +125,43 @@ private constructor( fun timesRedeemed(): Long = timesRedeemed.getRequired("times_redeemed") /** Also referred to as coupon_id in this documentation. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * An archived coupon can no longer be redeemed. Active coupons will have a value of null for * `archived_at`; this field will be non-null for archived coupons. */ - @JsonProperty("archived_at") @ExcludeMissing fun _archivedAt() = archivedAt + @JsonProperty("archived_at") + @ExcludeMissing + fun _archivedAt(): JsonField = archivedAt - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** * This allows for a coupon's discount to apply for a limited time (determined in months); a * `null` value here means "unlimited time". */ - @JsonProperty("duration_in_months") @ExcludeMissing fun _durationInMonths() = durationInMonths + @JsonProperty("duration_in_months") + @ExcludeMissing + fun _durationInMonths(): JsonField = durationInMonths /** * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` here * means "unlimited". */ - @JsonProperty("max_redemptions") @ExcludeMissing fun _maxRedemptions() = maxRedemptions + @JsonProperty("max_redemptions") + @ExcludeMissing + fun _maxRedemptions(): JsonField = maxRedemptions /** This string can be used to redeem this coupon for a given subscription. */ - @JsonProperty("redemption_code") @ExcludeMissing fun _redemptionCode() = redemptionCode + @JsonProperty("redemption_code") + @ExcludeMissing + fun _redemptionCode(): JsonField = redemptionCode /** The number of times this coupon has been redeemed. */ - @JsonProperty("times_redeemed") @ExcludeMissing fun _timesRedeemed() = timesRedeemed + @JsonProperty("times_redeemed") + @ExcludeMissing + fun _timesRedeemed(): JsonField = timesRedeemed @JsonAnyGetter @ExcludeMissing @@ -181,13 +191,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var archivedAt: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var durationInMonths: JsonField = JsonMissing.of() - private var maxRedemptions: JsonField = JsonMissing.of() - private var redemptionCode: JsonField = JsonMissing.of() - private var timesRedeemed: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var archivedAt: JsonField? = null + private var discount: JsonField? = null + private var durationInMonths: JsonField? = null + private var maxRedemptions: JsonField? = null + private var redemptionCode: JsonField? = null + private var timesRedeemed: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -212,7 +222,13 @@ private constructor( * An archived coupon can no longer be redeemed. Active coupons will have a value of null * for `archived_at`; this field will be non-null for archived coupons. */ - fun archivedAt(archivedAt: OffsetDateTime) = archivedAt(JsonField.of(archivedAt)) + fun archivedAt(archivedAt: OffsetDateTime?) = archivedAt(JsonField.ofNullable(archivedAt)) + + /** + * An archived coupon can no longer be redeemed. Active coupons will have a value of null + * for `archived_at`; this field will be non-null for archived coupons. + */ + fun archivedAt(archivedAt: Optional) = archivedAt(archivedAt.orElse(null)) /** * An archived coupon can no longer be redeemed. Active coupons will have a value of null @@ -226,12 +242,32 @@ private constructor( fun discount(discount: JsonField) = apply { this.discount = discount } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + /** * This allows for a coupon's discount to apply for a limited time (determined in months); a * `null` value here means "unlimited time". */ - fun durationInMonths(durationInMonths: Long) = - durationInMonths(JsonField.of(durationInMonths)) + fun durationInMonths(durationInMonths: Long?) = + durationInMonths(JsonField.ofNullable(durationInMonths)) + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(durationInMonths: Long) = durationInMonths(durationInMonths as Long?) + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun durationInMonths(durationInMonths: Optional) = + durationInMonths(durationInMonths.orElse(null) as Long?) /** * This allows for a coupon's discount to apply for a limited time (determined in months); a @@ -245,7 +281,22 @@ private constructor( * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` * here means "unlimited". */ - fun maxRedemptions(maxRedemptions: Long) = maxRedemptions(JsonField.of(maxRedemptions)) + fun maxRedemptions(maxRedemptions: Long?) = + maxRedemptions(JsonField.ofNullable(maxRedemptions)) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` + * here means "unlimited". + */ + fun maxRedemptions(maxRedemptions: Long) = maxRedemptions(maxRedemptions as Long?) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` + * here means "unlimited". + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maxRedemptions(maxRedemptions: Optional) = + maxRedemptions(maxRedemptions.orElse(null) as Long?) /** * The maximum number of redemptions allowed for this coupon before it is exhausted; `null` @@ -292,13 +343,13 @@ private constructor( fun build(): Coupon = Coupon( - id, - archivedAt, - discount, - durationInMonths, - maxRedemptions, - redemptionCode, - timesRedeemed, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(archivedAt) { "`archivedAt` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(durationInMonths) { "`durationInMonths` is required but was not set" }, + checkNotNull(maxRedemptions) { "`maxRedemptions` is required but was not set" }, + checkNotNull(redemptionCode) { "`redemptionCode` is required but was not set" }, + checkNotNull(timesRedeemed) { "`timesRedeemed` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt index 02209378..890b6957 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponArchiveParams.kt @@ -10,6 +10,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows a coupon to be archived. Archived coupons can no longer be redeemed, and + * will be hidden from lists of active coupons. Additionally, once a coupon is archived, its + * redemption code can be reused for a different coupon. + */ class CouponArchiveParams constructor( private val couponId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt index e3b39047..cb4aa833 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponCreateParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,10 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint allows the creation of coupons, which can then be redeemed at subscription creation + * or plan change. + */ class CouponCreateParams constructor( private val body: CouponCreateBody, @@ -54,12 +59,29 @@ constructor( */ fun maxRedemptions(): Optional = body.maxRedemptions() - fun _additionalHeaders(): Headers = additionalHeaders + fun _discount(): JsonField = body._discount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** This string can be used to redeem this coupon for a given subscription. */ + fun _redemptionCode(): JsonField = body._redemptionCode() + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun _durationInMonths(): JsonField = body._durationInMonths() + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted;`null` here + * means "unlimited". + */ + fun _maxRedemptions(): JsonField = body._maxRedemptions() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CouponCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -70,37 +92,80 @@ constructor( class CouponCreateBody @JsonCreator internal constructor( - @JsonProperty("discount") private val discount: Discount, - @JsonProperty("redemption_code") private val redemptionCode: String, - @JsonProperty("duration_in_months") private val durationInMonths: Long?, - @JsonProperty("max_redemptions") private val maxRedemptions: Long?, + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("redemption_code") + @ExcludeMissing + private val redemptionCode: JsonField = JsonMissing.of(), + @JsonProperty("duration_in_months") + @ExcludeMissing + private val durationInMonths: JsonField = JsonMissing.of(), + @JsonProperty("max_redemptions") + @ExcludeMissing + private val maxRedemptions: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount") fun discount(): Discount = discount + fun discount(): Discount = discount.getRequired("discount") /** This string can be used to redeem this coupon for a given subscription. */ - @JsonProperty("redemption_code") fun redemptionCode(): String = redemptionCode + fun redemptionCode(): String = redemptionCode.getRequired("redemption_code") + + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(): Optional = + Optional.ofNullable(durationInMonths.getNullable("duration_in_months")) + + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted;`null` + * here means "unlimited". + */ + fun maxRedemptions(): Optional = + Optional.ofNullable(maxRedemptions.getNullable("max_redemptions")) + + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount + + /** This string can be used to redeem this coupon for a given subscription. */ + @JsonProperty("redemption_code") + @ExcludeMissing + fun _redemptionCode(): JsonField = redemptionCode /** * This allows for a coupon's discount to apply for a limited time (determined in months); a * `null` value here means "unlimited time". */ @JsonProperty("duration_in_months") - fun durationInMonths(): Optional = Optional.ofNullable(durationInMonths) + @ExcludeMissing + fun _durationInMonths(): JsonField = durationInMonths /** * The maximum number of redemptions allowed for this coupon before it is exhausted;`null` * here means "unlimited". */ @JsonProperty("max_redemptions") - fun maxRedemptions(): Optional = Optional.ofNullable(maxRedemptions) + @ExcludeMissing + fun _maxRedemptions(): JsonField = maxRedemptions @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CouponCreateBody = apply { + if (!validated) { + discount() + redemptionCode() + durationInMonths() + maxRedemptions() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -110,10 +175,10 @@ constructor( class Builder { - private var discount: Discount? = null - private var redemptionCode: String? = null - private var durationInMonths: Long? = null - private var maxRedemptions: Long? = null + private var discount: JsonField? = null + private var redemptionCode: JsonField? = null + private var durationInMonths: JsonField = JsonMissing.of() + private var maxRedemptions: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -125,20 +190,22 @@ constructor( additionalProperties = couponCreateBody.additionalProperties.toMutableMap() } - fun discount(discount: Discount) = apply { this.discount = discount } + fun discount(discount: Discount) = discount(JsonField.of(discount)) + + fun discount(discount: JsonField) = apply { this.discount = discount } fun discount(newCouponPercentageDiscount: Discount.NewCouponPercentageDiscount) = - apply { - this.discount = - Discount.ofNewCouponPercentageDiscount(newCouponPercentageDiscount) - } + discount(Discount.ofNewCouponPercentageDiscount(newCouponPercentageDiscount)) - fun discount(newCouponAmountDiscount: Discount.NewCouponAmountDiscount) = apply { - this.discount = Discount.ofNewCouponAmountDiscount(newCouponAmountDiscount) - } + fun discount(newCouponAmountDiscount: Discount.NewCouponAmountDiscount) = + discount(Discount.ofNewCouponAmountDiscount(newCouponAmountDiscount)) + + /** This string can be used to redeem this coupon for a given subscription. */ + fun redemptionCode(redemptionCode: String) = + redemptionCode(JsonField.of(redemptionCode)) /** This string can be used to redeem this coupon for a given subscription. */ - fun redemptionCode(redemptionCode: String) = apply { + fun redemptionCode(redemptionCode: JsonField) = apply { this.redemptionCode = redemptionCode } @@ -146,9 +213,8 @@ constructor( * This allows for a coupon's discount to apply for a limited time (determined in * months); a `null` value here means "unlimited time". */ - fun durationInMonths(durationInMonths: Long?) = apply { - this.durationInMonths = durationInMonths - } + fun durationInMonths(durationInMonths: Long?) = + durationInMonths(JsonField.ofNullable(durationInMonths)) /** * This allows for a coupon's discount to apply for a limited time (determined in @@ -165,13 +231,20 @@ constructor( fun durationInMonths(durationInMonths: Optional) = durationInMonths(durationInMonths.orElse(null) as Long?) + /** + * This allows for a coupon's discount to apply for a limited time (determined in + * months); a `null` value here means "unlimited time". + */ + fun durationInMonths(durationInMonths: JsonField) = apply { + this.durationInMonths = durationInMonths + } + /** * The maximum number of redemptions allowed for this coupon before it is * exhausted;`null` here means "unlimited". */ - fun maxRedemptions(maxRedemptions: Long?) = apply { - this.maxRedemptions = maxRedemptions - } + fun maxRedemptions(maxRedemptions: Long?) = + maxRedemptions(JsonField.ofNullable(maxRedemptions)) /** * The maximum number of redemptions allowed for this coupon before it is @@ -187,6 +260,14 @@ constructor( fun maxRedemptions(maxRedemptions: Optional) = maxRedemptions(maxRedemptions.orElse(null) as Long?) + /** + * The maximum number of redemptions allowed for this coupon before it is + * exhausted;`null` here means "unlimited". + */ + fun maxRedemptions(maxRedemptions: JsonField) = apply { + this.maxRedemptions = maxRedemptions + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -257,6 +338,8 @@ constructor( fun discount(discount: Discount) = apply { body.discount(discount) } + fun discount(discount: JsonField) = apply { body.discount(discount) } + fun discount(newCouponPercentageDiscount: Discount.NewCouponPercentageDiscount) = apply { body.discount(newCouponPercentageDiscount) } @@ -268,6 +351,11 @@ constructor( /** This string can be used to redeem this coupon for a given subscription. */ fun redemptionCode(redemptionCode: String) = apply { body.redemptionCode(redemptionCode) } + /** This string can be used to redeem this coupon for a given subscription. */ + fun redemptionCode(redemptionCode: JsonField) = apply { + body.redemptionCode(redemptionCode) + } + /** * This allows for a coupon's discount to apply for a limited time (determined in months); a * `null` value here means "unlimited time". @@ -290,6 +378,14 @@ constructor( fun durationInMonths(durationInMonths: Optional) = durationInMonths(durationInMonths.orElse(null) as Long?) + /** + * This allows for a coupon's discount to apply for a limited time (determined in months); a + * `null` value here means "unlimited time". + */ + fun durationInMonths(durationInMonths: JsonField) = apply { + body.durationInMonths(durationInMonths) + } + /** * The maximum number of redemptions allowed for this coupon before it is exhausted;`null` * here means "unlimited". @@ -310,6 +406,33 @@ constructor( fun maxRedemptions(maxRedemptions: Optional) = maxRedemptions(maxRedemptions.orElse(null) as Long?) + /** + * The maximum number of redemptions allowed for this coupon before it is exhausted;`null` + * here means "unlimited". + */ + fun maxRedemptions(maxRedemptions: JsonField) = apply { + body.maxRedemptions(maxRedemptions) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -408,25 +531,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CouponCreateParams = CouponCreateParams( body.build(), @@ -444,6 +548,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newCouponPercentageDiscount(): Optional = Optional.ofNullable(newCouponPercentageDiscount) @@ -472,6 +578,17 @@ constructor( } } + fun validate(): Discount = apply { + if (!validated) { + if (newCouponPercentageDiscount == null && newCouponAmountDiscount == null) { + throw OrbInvalidDataException("Unknown Discount: $_json") + } + newCouponPercentageDiscount?.validate() + newCouponAmountDiscount?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -526,14 +643,20 @@ constructor( when (discountType) { "percentage" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Discount(newCouponPercentageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Discount(newCouponPercentageDiscount = it, _json = json) + } } "amount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Discount(newCouponAmountDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Discount(newCouponAmountDiscount = it, _json = json) + } } } @@ -563,21 +686,42 @@ constructor( class NewCouponPercentageDiscount @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + fun percentageDiscount(): Double = percentageDiscount.getRequired("percentage_discount") + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewCouponPercentageDiscount = apply { + if (!validated) { + discountType() + percentageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -587,8 +731,8 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var percentageDiscount: Double? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -600,11 +744,17 @@ constructor( newCouponPercentageDiscount.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } - fun percentageDiscount(percentageDiscount: Double) = apply { + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + fun percentageDiscount(percentageDiscount: JsonField) = apply { this.percentageDiscount = percentageDiscount } @@ -713,20 +863,42 @@ constructor( class NewCouponAmountDiscount @JsonCreator private constructor( - @JsonProperty("amount_discount") private val amountDiscount: String, - @JsonProperty("discount_type") private val discountType: DiscountType, + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("amount_discount") fun amountDiscount(): String = amountDiscount + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewCouponAmountDiscount = apply { + if (!validated) { + amountDiscount() + discountType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -736,8 +908,8 @@ constructor( class Builder { - private var amountDiscount: String? = null - private var discountType: DiscountType? = null + private var amountDiscount: JsonField? = null + private var discountType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -748,11 +920,17 @@ constructor( newCouponAmountDiscount.additionalProperties.toMutableMap() } - fun amountDiscount(amountDiscount: String) = apply { + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt index 6dca4c54..e5c69f2d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponFetchParams.kt @@ -7,6 +7,10 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption code, use the + * [List coupons](list-coupons) endpoint with the redemption_code parameter. + */ class CouponFetchParams constructor( private val couponId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt index 14f5711e..4fc6ac77 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponListParams.kt @@ -8,6 +8,13 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all coupons for an account in a list format. + * + * The list of coupons is ordered starting from the most recently created coupon. The response also + * includes `pagination_metadata`, which lets the caller retrieve the next page of results if they + * exist. More information about pagination can be found in the Pagination-metadata schema. + */ class CouponListParams constructor( private val cursor: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt index c96c78be..b52424ad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CouponSubscriptionListParams.kt @@ -8,6 +8,12 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all subscriptions that have redeemed a given coupon as a + * [paginated](../reference/pagination) list, ordered starting from the most recently created + * subscription. For a full discussion of the subscription resource, see + * [Subscription](../guides/concepts#subscription). + */ class CouponSubscriptionListParams constructor( private val couponId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt index 85aa4b0f..a6d6497e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNote.kt @@ -121,53 +121,63 @@ private constructor( Optional.ofNullable(discounts.getNullable("discounts")) /** The Orb id of this credit note. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The creation time of the resource in Orb. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** The unique identifier for credit notes. */ - @JsonProperty("credit_note_number") @ExcludeMissing fun _creditNoteNumber() = creditNoteNumber + @JsonProperty("credit_note_number") + @ExcludeMissing + fun _creditNoteNumber(): JsonField = creditNoteNumber /** A URL to a PDF of the credit note. */ - @JsonProperty("credit_note_pdf") @ExcludeMissing fun _creditNotePdf() = creditNotePdf + @JsonProperty("credit_note_pdf") + @ExcludeMissing + fun _creditNotePdf(): JsonField = creditNotePdf - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** The id of the invoice resource that this credit note is applied to. */ - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId() = invoiceId + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId /** All of the line items associated with this credit note. */ - @JsonProperty("line_items") @ExcludeMissing fun _lineItems() = lineItems + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems /** The maximum amount applied on the original invoice */ @JsonProperty("maximum_amount_adjustment") @ExcludeMissing - fun _maximumAmountAdjustment() = maximumAmountAdjustment + fun _maximumAmountAdjustment(): JsonField = maximumAmountAdjustment /** An optional memo supplied on the credit note. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** Any credited amount from the applied minimum on the invoice. */ @JsonProperty("minimum_amount_refunded") @ExcludeMissing - fun _minimumAmountRefunded() = minimumAmountRefunded + fun _minimumAmountRefunded(): JsonField = minimumAmountRefunded - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** The total prior to any creditable invoice-level discounts or minimums. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** The total including creditable invoice-level discounts or minimums, and tax. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** The time at which the credit note was voided in Orb, if applicable. */ - @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt() = voidedAt + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt /** Any discounts applied on the original invoice. */ - @JsonProperty("discounts") @ExcludeMissing fun _discounts() = discounts + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts @JsonAnyGetter @ExcludeMissing @@ -206,22 +216,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNoteNumber: JsonField = JsonMissing.of() - private var creditNotePdf: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var invoiceId: JsonField = JsonMissing.of() - private var lineItems: JsonField> = JsonMissing.of() - private var maximumAmountAdjustment: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var minimumAmountRefunded: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var voidedAt: JsonField = JsonMissing.of() - private var discounts: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var creditNotePdf: JsonField? = null + private var customer: JsonField? = null + private var invoiceId: JsonField? = null + private var lineItems: JsonField>? = null + private var maximumAmountAdjustment: JsonField? = null + private var memo: JsonField? = null + private var minimumAmountRefunded: JsonField? = null + private var reason: JsonField? = null + private var subtotal: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null + private var discounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -232,7 +242,7 @@ private constructor( creditNotePdf = creditNote.creditNotePdf customer = creditNote.customer invoiceId = creditNote.invoiceId - lineItems = creditNote.lineItems + lineItems = creditNote.lineItems.map { it.toMutableList() } maximumAmountAdjustment = creditNote.maximumAmountAdjustment memo = creditNote.memo minimumAmountRefunded = creditNote.minimumAmountRefunded @@ -241,7 +251,7 @@ private constructor( total = creditNote.total type = creditNote.type voidedAt = creditNote.voidedAt - discounts = creditNote.discounts + discounts = creditNote.discounts.map { it.toMutableList() } additionalProperties = creditNote.additionalProperties.toMutableMap() } @@ -267,7 +277,12 @@ private constructor( } /** A URL to a PDF of the credit note. */ - fun creditNotePdf(creditNotePdf: String) = creditNotePdf(JsonField.of(creditNotePdf)) + fun creditNotePdf(creditNotePdf: String?) = + creditNotePdf(JsonField.ofNullable(creditNotePdf)) + + /** A URL to a PDF of the credit note. */ + fun creditNotePdf(creditNotePdf: Optional) = + creditNotePdf(creditNotePdf.orElse(null)) /** A URL to a PDF of the credit note. */ fun creditNotePdf(creditNotePdf: JsonField) = apply { @@ -288,11 +303,31 @@ private constructor( fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) /** All of the line items associated with this credit note. */ - fun lineItems(lineItems: JsonField>) = apply { this.lineItems = lineItems } + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } + } + + /** All of the line items associated with this credit note. */ + fun addLineItem(lineItem: LineItem) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(lineItem) + } + } /** The maximum amount applied on the original invoice */ - fun maximumAmountAdjustment(maximumAmountAdjustment: MaximumAmountAdjustment) = - maximumAmountAdjustment(JsonField.of(maximumAmountAdjustment)) + fun maximumAmountAdjustment(maximumAmountAdjustment: MaximumAmountAdjustment?) = + maximumAmountAdjustment(JsonField.ofNullable(maximumAmountAdjustment)) + + /** The maximum amount applied on the original invoice */ + fun maximumAmountAdjustment(maximumAmountAdjustment: Optional) = + maximumAmountAdjustment(maximumAmountAdjustment.orElse(null)) /** The maximum amount applied on the original invoice */ fun maximumAmountAdjustment(maximumAmountAdjustment: JsonField) = @@ -301,21 +336,30 @@ private constructor( } /** An optional memo supplied on the credit note. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo supplied on the credit note. */ fun memo(memo: JsonField) = apply { this.memo = memo } /** Any credited amount from the applied minimum on the invoice. */ - fun minimumAmountRefunded(minimumAmountRefunded: String) = - minimumAmountRefunded(JsonField.of(minimumAmountRefunded)) + fun minimumAmountRefunded(minimumAmountRefunded: String?) = + minimumAmountRefunded(JsonField.ofNullable(minimumAmountRefunded)) + + /** Any credited amount from the applied minimum on the invoice. */ + fun minimumAmountRefunded(minimumAmountRefunded: Optional) = + minimumAmountRefunded(minimumAmountRefunded.orElse(null)) /** Any credited amount from the applied minimum on the invoice. */ fun minimumAmountRefunded(minimumAmountRefunded: JsonField) = apply { this.minimumAmountRefunded = minimumAmountRefunded } - fun reason(reason: Reason) = reason(JsonField.of(reason)) + fun reason(reason: Reason?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -336,7 +380,10 @@ private constructor( fun type(type: JsonField) = apply { this.type = type } /** The time at which the credit note was voided in Orb, if applicable. */ - fun voidedAt(voidedAt: OffsetDateTime) = voidedAt(JsonField.of(voidedAt)) + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** The time at which the credit note was voided in Orb, if applicable. */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) /** The time at which the credit note was voided in Orb, if applicable. */ fun voidedAt(voidedAt: JsonField) = apply { this.voidedAt = voidedAt } @@ -345,7 +392,23 @@ private constructor( fun discounts(discounts: List) = discounts(JsonField.of(discounts)) /** Any discounts applied on the original invoice. */ - fun discounts(discounts: JsonField>) = apply { this.discounts = discounts } + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + + /** Any discounts applied on the original invoice. */ + fun addDiscount(discount: Discount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -368,22 +431,27 @@ private constructor( fun build(): CreditNote = CreditNote( - id, - createdAt, - creditNoteNumber, - creditNotePdf, - customer, - invoiceId, - lineItems.map { it.toImmutable() }, - maximumAmountAdjustment, - memo, - minimumAmountRefunded, - reason, - subtotal, - total, - type, - voidedAt, - discounts.map { it.toImmutable() }, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNoteNumber) { "`creditNoteNumber` is required but was not set" }, + checkNotNull(creditNotePdf) { "`creditNotePdf` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, + checkNotNull(lineItems) { "`lineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(maximumAmountAdjustment) { + "`maximumAmountAdjustment` is required but was not set" + }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(minimumAmountRefunded) { + "`minimumAmountRefunded` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(voidedAt) { "`voidedAt` is required but was not set" }, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -405,11 +473,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -434,8 +502,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -449,8 +517,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -477,8 +548,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -551,25 +624,29 @@ private constructor( Optional.ofNullable(discounts.getNullable("discounts")) /** The Orb id of this resource. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount of the line item, including any line item minimums and discounts. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The name of the corresponding invoice line item. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** An optional quantity credited. */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** The amount of the line item, excluding any line item minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** Any tax amounts applied onto the line item. */ - @JsonProperty("tax_amounts") @ExcludeMissing fun _taxAmounts() = taxAmounts + @JsonProperty("tax_amounts") + @ExcludeMissing + fun _taxAmounts(): JsonField> = taxAmounts /** Any line item discounts from the invoice's line item. */ - @JsonProperty("discounts") @ExcludeMissing fun _discounts() = discounts + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts @JsonAnyGetter @ExcludeMissing @@ -599,13 +676,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var taxAmounts: JsonField> = JsonMissing.of() - private var discounts: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var subtotal: JsonField? = null + private var taxAmounts: JsonField>? = null + private var discounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -615,8 +692,8 @@ private constructor( name = lineItem.name quantity = lineItem.quantity subtotal = lineItem.subtotal - taxAmounts = lineItem.taxAmounts - discounts = lineItem.discounts + taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } + discounts = lineItem.discounts.map { it.toMutableList() } additionalProperties = lineItem.additionalProperties.toMutableMap() } @@ -639,7 +716,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } /** An optional quantity credited. */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** An optional quantity credited. */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** An optional quantity credited. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun quantity(quantity: Optional) = quantity(quantity.orElse(null) as Double?) /** An optional quantity credited. */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -655,7 +739,21 @@ private constructor( /** Any tax amounts applied onto the line item. */ fun taxAmounts(taxAmounts: JsonField>) = apply { - this.taxAmounts = taxAmounts + this.taxAmounts = taxAmounts.map { it.toMutableList() } + } + + /** Any tax amounts applied onto the line item. */ + fun addTaxAmount(taxAmount: TaxAmount) = apply { + taxAmounts = + (taxAmounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(taxAmount) + } } /** Any line item discounts from the invoice's line item. */ @@ -663,7 +761,21 @@ private constructor( /** Any line item discounts from the invoice's line item. */ fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts + this.discounts = discounts.map { it.toMutableList() } + } + + /** Any line item discounts from the invoice's line item. */ + fun addDiscount(discount: Discount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -687,13 +799,14 @@ private constructor( fun build(): LineItem = LineItem( - id, - amount, - name, - quantity, - subtotal, - taxAmounts.map { it.toImmutable() }, - discounts.map { it.toImmutable() }, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(taxAmounts) { "`taxAmounts` is required but was not set" } + .map { it.toImmutable() }, + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -727,17 +840,17 @@ private constructor( Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The human-readable description of the applied tax rate. */ @JsonProperty("tax_rate_description") @ExcludeMissing - fun _taxRateDescription() = taxRateDescription + fun _taxRateDescription(): JsonField = taxRateDescription /** The tax rate percentage, out of 100. */ @JsonProperty("tax_rate_percentage") @ExcludeMissing - fun _taxRatePercentage() = taxRatePercentage + fun _taxRatePercentage(): JsonField = taxRatePercentage @JsonAnyGetter @ExcludeMissing @@ -763,9 +876,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var taxRateDescription: JsonField = JsonMissing.of() - private var taxRatePercentage: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var taxRateDescription: JsonField? = null + private var taxRatePercentage: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -792,8 +905,12 @@ private constructor( } /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String) = - taxRatePercentage(JsonField.of(taxRatePercentage)) + fun taxRatePercentage(taxRatePercentage: String?) = + taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: Optional) = + taxRatePercentage(taxRatePercentage.orElse(null)) /** The tax rate percentage, out of 100. */ fun taxRatePercentage(taxRatePercentage: JsonField) = apply { @@ -824,9 +941,13 @@ private constructor( fun build(): TaxAmount = TaxAmount( - amount, - taxRateDescription, - taxRatePercentage, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(taxRateDescription) { + "`taxRateDescription` is required but was not set" + }, + checkNotNull(taxRatePercentage) { + "`taxRatePercentage` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -894,23 +1015,29 @@ private constructor( fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount_applied") @ExcludeMissing fun _amountApplied() = amountApplied + @JsonProperty("amount_applied") + @ExcludeMissing + fun _amountApplied(): JsonField = amountApplied @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -940,11 +1067,11 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amountApplied: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amountApplied: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null private var amountDiscount: JsonField = JsonMissing.of() private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -953,7 +1080,7 @@ private constructor( internal fun from(discount: Discount) = apply { id = discount.id amountApplied = discount.amountApplied - appliesToPriceIds = discount.appliesToPriceIds + appliesToPriceIds = discount.appliesToPriceIds.map { it.toMutableList() } discountType = discount.discountType percentageDiscount = discount.percentageDiscount amountDiscount = discount.amountDiscount @@ -976,7 +1103,20 @@ private constructor( appliesToPriceIds(JsonField.of(appliesToPriceIds)) fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } fun discountType(discountType: DiscountType) = @@ -993,14 +1133,19 @@ private constructor( this.percentageDiscount = percentageDiscount } - fun amountDiscount(amountDiscount: String) = - amountDiscount(JsonField.of(amountDiscount)) + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) + + fun amountDiscount(amountDiscount: Optional) = + amountDiscount(amountDiscount.orElse(null)) fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1028,11 +1173,18 @@ private constructor( fun build(): Discount = Discount( - id, - amountApplied, - appliesToPriceIds.map { it.toImmutable() }, - discountType, - percentageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amountApplied) { + "`amountApplied` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, amountDiscount, reason, additionalProperties.toImmutable(), @@ -1167,17 +1319,23 @@ private constructor( fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("amount_applied") @ExcludeMissing fun _amountApplied() = amountApplied + @JsonProperty("amount_applied") + @ExcludeMissing + fun _amountApplied(): JsonField = amountApplied - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount - @JsonProperty("applies_to_prices") @ExcludeMissing fun _appliesToPrices() = appliesToPrices + @JsonProperty("applies_to_prices") + @ExcludeMissing + fun _appliesToPrices(): JsonField> = appliesToPrices - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1205,10 +1363,10 @@ private constructor( class Builder { - private var amountApplied: JsonField = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var appliesToPrices: JsonField> = JsonMissing.of() + private var amountApplied: JsonField? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null + private var appliesToPrices: JsonField>? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1217,7 +1375,7 @@ private constructor( amountApplied = maximumAmountAdjustment.amountApplied discountType = maximumAmountAdjustment.discountType percentageDiscount = maximumAmountAdjustment.percentageDiscount - appliesToPrices = maximumAmountAdjustment.appliesToPrices + appliesToPrices = maximumAmountAdjustment.appliesToPrices.map { it.toMutableList() } reason = maximumAmountAdjustment.reason additionalProperties = maximumAmountAdjustment.additionalProperties.toMutableMap() } @@ -1241,14 +1399,32 @@ private constructor( this.percentageDiscount = percentageDiscount } - fun appliesToPrices(appliesToPrices: List) = - appliesToPrices(JsonField.of(appliesToPrices)) + fun appliesToPrices(appliesToPrices: List?) = + appliesToPrices(JsonField.ofNullable(appliesToPrices)) + + fun appliesToPrices(appliesToPrices: Optional>) = + appliesToPrices(appliesToPrices.orElse(null)) fun appliesToPrices(appliesToPrices: JsonField>) = apply { - this.appliesToPrices = appliesToPrices + this.appliesToPrices = appliesToPrices.map { it.toMutableList() } + } + + fun addAppliesToPrice(appliesToPrice: AppliesToPrice) = apply { + appliesToPrices = + (appliesToPrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPrice) + } } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1273,10 +1449,12 @@ private constructor( fun build(): MaximumAmountAdjustment = MaximumAmountAdjustment( - amountApplied, - discountType, - percentageDiscount, - appliesToPrices.map { it.toImmutable() }, + checkNotNull(amountApplied) { "`amountApplied` is required but was not set" }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + (appliesToPrices ?: JsonMissing.of()).map { it.toImmutable() }, reason, additionalProperties.toImmutable(), ) @@ -1351,9 +1529,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1378,8 +1556,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1421,8 +1599,8 @@ private constructor( fun build(): AppliesToPrice = AppliesToPrice( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1623,17 +1801,23 @@ private constructor( fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("amount_applied") @ExcludeMissing fun _amountApplied() = amountApplied + @JsonProperty("amount_applied") + @ExcludeMissing + fun _amountApplied(): JsonField = amountApplied - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount - @JsonProperty("applies_to_prices") @ExcludeMissing fun _appliesToPrices() = appliesToPrices + @JsonProperty("applies_to_prices") + @ExcludeMissing + fun _appliesToPrices(): JsonField> = appliesToPrices - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1661,10 +1845,10 @@ private constructor( class Builder { - private var amountApplied: JsonField = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var appliesToPrices: JsonField> = JsonMissing.of() + private var amountApplied: JsonField? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null + private var appliesToPrices: JsonField>? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1673,7 +1857,7 @@ private constructor( amountApplied = discount.amountApplied discountType = discount.discountType percentageDiscount = discount.percentageDiscount - appliesToPrices = discount.appliesToPrices + appliesToPrices = discount.appliesToPrices.map { it.toMutableList() } reason = discount.reason additionalProperties = discount.additionalProperties.toMutableMap() } @@ -1697,14 +1881,32 @@ private constructor( this.percentageDiscount = percentageDiscount } - fun appliesToPrices(appliesToPrices: List) = - appliesToPrices(JsonField.of(appliesToPrices)) + fun appliesToPrices(appliesToPrices: List?) = + appliesToPrices(JsonField.ofNullable(appliesToPrices)) + + fun appliesToPrices(appliesToPrices: Optional>) = + appliesToPrices(appliesToPrices.orElse(null)) fun appliesToPrices(appliesToPrices: JsonField>) = apply { - this.appliesToPrices = appliesToPrices + this.appliesToPrices = appliesToPrices.map { it.toMutableList() } + } + + fun addAppliesToPrice(appliesToPrice: AppliesToPrice) = apply { + appliesToPrices = + (appliesToPrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPrice) + } } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1729,10 +1931,12 @@ private constructor( fun build(): Discount = Discount( - amountApplied, - discountType, - percentageDiscount, - appliesToPrices.map { it.toImmutable() }, + checkNotNull(amountApplied) { "`amountApplied` is required but was not set" }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + (appliesToPrices ?: JsonMissing.of()).map { it.toImmutable() }, reason, additionalProperties.toImmutable(), ) @@ -1807,9 +2011,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -1834,8 +2038,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1877,8 +2081,8 @@ private constructor( fun build(): AppliesToPrice = AppliesToPrice( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt index 3d26c038..fe6f6d13 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** This endpoint is used to create a single [`Credit Note`](../guides/invoicing/credit-notes). */ class CreditNoteCreateParams constructor( private val body: CreditNoteCreateBody, @@ -34,12 +36,20 @@ constructor( /** An optional reason for the credit note. */ fun reason(): Optional = body.reason() - fun _additionalHeaders(): Headers = additionalHeaders + fun _lineItems(): JsonField> = body._lineItems() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** An optional memo to attach to the credit note. */ + fun _memo(): JsonField = body._memo() + + /** An optional reason for the credit note. */ + fun _reason(): JsonField = body._reason() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CreditNoteCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -50,25 +60,52 @@ constructor( class CreditNoteCreateBody @JsonCreator internal constructor( - @JsonProperty("line_items") private val lineItems: List, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("reason") private val reason: Reason?, + @JsonProperty("line_items") + @ExcludeMissing + private val lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("reason") + @ExcludeMissing + private val reason: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("line_items") fun lineItems(): List = lineItems + fun lineItems(): List = lineItems.getRequired("line_items") /** An optional memo to attach to the credit note. */ - @JsonProperty("memo") fun memo(): Optional = Optional.ofNullable(memo) + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) /** An optional reason for the credit note. */ - @JsonProperty("reason") fun reason(): Optional = Optional.ofNullable(reason) + fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) + + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems + + /** An optional memo to attach to the credit note. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** An optional reason for the credit note. */ + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CreditNoteCreateBody = apply { + if (!validated) { + lineItems().forEach { it.validate() } + memo() + reason() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -78,39 +115,56 @@ constructor( class Builder { - private var lineItems: MutableList? = null - private var memo: String? = null - private var reason: Reason? = null + private var lineItems: JsonField>? = null + private var memo: JsonField = JsonMissing.of() + private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(creditNoteCreateBody: CreditNoteCreateBody) = apply { - lineItems = creditNoteCreateBody.lineItems.toMutableList() + lineItems = creditNoteCreateBody.lineItems.map { it.toMutableList() } memo = creditNoteCreateBody.memo reason = creditNoteCreateBody.reason additionalProperties = creditNoteCreateBody.additionalProperties.toMutableMap() } - fun lineItems(lineItems: List) = apply { - this.lineItems = lineItems.toMutableList() + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } } fun addLineItem(lineItem: LineItem) = apply { - lineItems = (lineItems ?: mutableListOf()).apply { add(lineItem) } + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(lineItem) + } } /** An optional memo to attach to the credit note. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** An optional memo to attach to the credit note. */ fun memo(memo: Optional) = memo(memo.orElse(null)) + /** An optional memo to attach to the credit note. */ + fun memo(memo: JsonField) = apply { this.memo = memo } + /** An optional reason for the credit note. */ - fun reason(reason: Reason?) = apply { this.reason = reason } + fun reason(reason: Reason?) = reason(JsonField.ofNullable(reason)) /** An optional reason for the credit note. */ fun reason(reason: Optional) = reason(reason.orElse(null)) + /** An optional reason for the credit note. */ + fun reason(reason: JsonField) = apply { this.reason = reason } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -133,7 +187,7 @@ constructor( fun build(): CreditNoteCreateBody = CreditNoteCreateBody( checkNotNull(lineItems) { "`lineItems` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, memo, reason, additionalProperties.toImmutable(), @@ -181,6 +235,8 @@ constructor( fun lineItems(lineItems: List) = apply { body.lineItems(lineItems) } + fun lineItems(lineItems: JsonField>) = apply { body.lineItems(lineItems) } + fun addLineItem(lineItem: LineItem) = apply { body.addLineItem(lineItem) } /** An optional memo to attach to the credit note. */ @@ -189,12 +245,37 @@ constructor( /** An optional memo to attach to the credit note. */ fun memo(memo: Optional) = memo(memo.orElse(null)) + /** An optional memo to attach to the credit note. */ + fun memo(memo: JsonField) = apply { body.memo(memo) } + /** An optional reason for the credit note. */ fun reason(reason: Reason?) = apply { body.reason(reason) } /** An optional reason for the credit note. */ fun reason(reason: Optional) = reason(reason.orElse(null)) + /** An optional reason for the credit note. */ + fun reason(reason: JsonField) = apply { body.reason(reason) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -293,25 +374,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CreditNoteCreateParams = CreditNoteCreateParams( body.build(), @@ -324,22 +386,44 @@ constructor( class LineItem @JsonCreator private constructor( - @JsonProperty("amount") private val amount: String, - @JsonProperty("invoice_line_item_id") private val invoiceLineItemId: String, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("invoice_line_item_id") + @ExcludeMissing + private val invoiceLineItemId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The total amount in the invoice's currency to credit this line item. */ - @JsonProperty("amount") fun amount(): String = amount + fun amount(): String = amount.getRequired("amount") /** The ID of the line item to credit. */ - @JsonProperty("invoice_line_item_id") fun invoiceLineItemId(): String = invoiceLineItemId + fun invoiceLineItemId(): String = invoiceLineItemId.getRequired("invoice_line_item_id") + + /** The total amount in the invoice's currency to credit this line item. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The ID of the line item to credit. */ + @JsonProperty("invoice_line_item_id") + @ExcludeMissing + fun _invoiceLineItemId(): JsonField = invoiceLineItemId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): LineItem = apply { + if (!validated) { + amount() + invoiceLineItemId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -349,8 +433,8 @@ constructor( class Builder { - private var amount: String? = null - private var invoiceLineItemId: String? = null + private var amount: JsonField? = null + private var invoiceLineItemId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -361,10 +445,17 @@ constructor( } /** The total amount in the invoice's currency to credit this line item. */ - fun amount(amount: String) = apply { this.amount = amount } + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The total amount in the invoice's currency to credit this line item. */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The ID of the line item to credit. */ + fun invoiceLineItemId(invoiceLineItemId: String) = + invoiceLineItemId(JsonField.of(invoiceLineItemId)) /** The ID of the line item to credit. */ - fun invoiceLineItemId(invoiceLineItemId: String) = apply { + fun invoiceLineItemId(invoiceLineItemId: JsonField) = apply { this.invoiceLineItemId = invoiceLineItemId } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt index d61ea776..8bab5025 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteFetchParams.kt @@ -7,6 +7,10 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch a single [`Credit Note`](../guides/invoicing/credit-notes) given + * an identifier. + */ class CreditNoteFetchParams constructor( private val creditNoteId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt index 4724e9eb..c7e1ca90 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CreditNoteListParams.kt @@ -8,6 +8,11 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * Get a paginated list of CreditNotes. Users can also filter by customer_id, subscription_id, or + * external_customer_id. The credit notes will be returned in reverse chronological order by + * `creation_time`. + */ class CreditNoteListParams constructor( private val cursor: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt index bc43cd06..7b11965f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Customer.kt @@ -287,32 +287,42 @@ private constructor( fun reportingConfiguration(): Optional = Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("additional_emails") @ExcludeMissing fun _additionalEmails() = additionalEmails + @JsonProperty("additional_emails") + @ExcludeMissing + fun _additionalEmails(): JsonField> = additionalEmails - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** The customer's current balance in their currency. */ - @JsonProperty("balance") @ExcludeMissing fun _balance() = balance + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance - @JsonProperty("billing_address") @ExcludeMissing fun _billingAddress() = billingAddress + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * A valid customer email, to be used for notifications. When Orb triggers payment through a * payment gateway, this email will be used for any automatically issued receipts. */ - @JsonProperty("email") @ExcludeMissing fun _email() = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email - @JsonProperty("email_delivery") @ExcludeMissing fun _emailDelivery() = emailDelivery + @JsonProperty("email_delivery") + @ExcludeMissing + fun _emailDelivery(): JsonField = emailDelivery @JsonProperty("exempt_from_automated_tax") @ExcludeMissing - fun _exemptFromAutomatedTax() = exemptFromAutomatedTax + fun _exemptFromAutomatedTax(): JsonField = exemptFromAutomatedTax /** * An optional user-defined ID for this customer resource, used throughout the system as an @@ -321,23 +331,25 @@ private constructor( */ @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The full name of the customer */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * This is used for creating charges or invoices in an external system via Orb. When not in test * mode, the connection must first be configured in the Orb webapp. */ - @JsonProperty("payment_provider") @ExcludeMissing fun _paymentProvider() = paymentProvider + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider /** * The ID of this customer in an external payments solution, such as Stripe. This is used for @@ -345,11 +357,13 @@ private constructor( */ @JsonProperty("payment_provider_id") @ExcludeMissing - fun _paymentProviderId() = paymentProviderId + fun _paymentProviderId(): JsonField = paymentProviderId - @JsonProperty("portal_url") @ExcludeMissing fun _portalUrl() = portalUrl + @JsonProperty("portal_url") @ExcludeMissing fun _portalUrl(): JsonField = portalUrl - @JsonProperty("shipping_address") @ExcludeMissing fun _shippingAddress() = shippingAddress + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to the @@ -457,22 +471,23 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("tax_id") @ExcludeMissing fun _taxId() = taxId + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId /** * A timezone identifier from the IANA timezone database, such as "America/Los_Angeles". This * "defaults to your account's timezone if not set. This cannot be changed after customer * creation. */ - @JsonProperty("timezone") @ExcludeMissing fun _timezone() = timezone + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone @JsonProperty("accounting_sync_configuration") @ExcludeMissing - fun _accountingSyncConfiguration() = accountingSyncConfiguration + fun _accountingSyncConfiguration(): JsonField = + accountingSyncConfiguration @JsonProperty("reporting_configuration") @ExcludeMissing - fun _reportingConfiguration() = reportingConfiguration + fun _reportingConfiguration(): JsonField = reportingConfiguration @JsonAnyGetter @ExcludeMissing @@ -516,25 +531,25 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var additionalEmails: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var billingAddress: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var email: JsonField = JsonMissing.of() - private var emailDelivery: JsonField = JsonMissing.of() - private var exemptFromAutomatedTax: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var paymentProvider: JsonField = JsonMissing.of() - private var paymentProviderId: JsonField = JsonMissing.of() - private var portalUrl: JsonField = JsonMissing.of() - private var shippingAddress: JsonField = JsonMissing.of() - private var taxId: JsonField = JsonMissing.of() - private var timezone: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var additionalEmails: JsonField>? = null + private var autoCollection: JsonField? = null + private var balance: JsonField? = null + private var billingAddress: JsonField? = null + private var createdAt: JsonField? = null + private var currency: JsonField? = null + private var email: JsonField? = null + private var emailDelivery: JsonField? = null + private var exemptFromAutomatedTax: JsonField? = null + private var externalCustomerId: JsonField? = null + private var metadata: JsonField? = null + private var name: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var portalUrl: JsonField? = null + private var shippingAddress: JsonField? = null + private var taxId: JsonField? = null + private var timezone: JsonField? = null private var accountingSyncConfiguration: JsonField = JsonMissing.of() private var reportingConfiguration: JsonField = JsonMissing.of() @@ -543,7 +558,7 @@ private constructor( @JvmSynthetic internal fun from(customer: Customer) = apply { id = customer.id - additionalEmails = customer.additionalEmails + additionalEmails = customer.additionalEmails.map { it.toMutableList() } autoCollection = customer.autoCollection balance = customer.balance billingAddress = customer.billingAddress @@ -574,7 +589,20 @@ private constructor( additionalEmails(JsonField.of(additionalEmails)) fun additionalEmails(additionalEmails: JsonField>) = apply { - this.additionalEmails = additionalEmails + this.additionalEmails = additionalEmails.map { it.toMutableList() } + } + + fun addAdditionalEmail(additionalEmail: String) = apply { + additionalEmails = + (additionalEmails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(additionalEmail) + } } fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) @@ -589,8 +617,11 @@ private constructor( /** The customer's current balance in their currency. */ fun balance(balance: JsonField) = apply { this.balance = balance } - fun billingAddress(billingAddress: BillingAddress) = - billingAddress(JsonField.of(billingAddress)) + fun billingAddress(billingAddress: BillingAddress?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.orElse(null)) fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress @@ -600,7 +631,9 @@ private constructor( fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun currency(currency: String) = currency(JsonField.of(currency)) + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + + fun currency(currency: Optional) = currency(currency.orElse(null)) fun currency(currency: JsonField) = apply { this.currency = currency } @@ -622,8 +655,15 @@ private constructor( this.emailDelivery = emailDelivery } + fun exemptFromAutomatedTax(exemptFromAutomatedTax: Boolean?) = + exemptFromAutomatedTax(JsonField.ofNullable(exemptFromAutomatedTax)) + fun exemptFromAutomatedTax(exemptFromAutomatedTax: Boolean) = - exemptFromAutomatedTax(JsonField.of(exemptFromAutomatedTax)) + exemptFromAutomatedTax(exemptFromAutomatedTax as Boolean?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun exemptFromAutomatedTax(exemptFromAutomatedTax: Optional) = + exemptFromAutomatedTax(exemptFromAutomatedTax.orElse(null) as Boolean?) fun exemptFromAutomatedTax(exemptFromAutomatedTax: JsonField) = apply { this.exemptFromAutomatedTax = exemptFromAutomatedTax @@ -634,8 +674,16 @@ private constructor( * alias for this Customer. Use this field to identify a customer by an existing identifier * in your system. */ - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier + * in your system. + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) /** * An optional user-defined ID for this customer resource, used throughout the system as an @@ -670,8 +718,15 @@ private constructor( * This is used for creating charges or invoices in an external system via Orb. When not in * test mode, the connection must first be configured in the Orb webapp. */ - fun paymentProvider(paymentProvider: PaymentProvider) = - paymentProvider(JsonField.of(paymentProvider)) + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.orElse(null)) /** * This is used for creating charges or invoices in an external system via Orb. When not in @@ -685,8 +740,15 @@ private constructor( * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: String) = - paymentProviderId(JsonField.of(paymentProviderId)) + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) /** * The ID of this customer in an external payments solution, such as Stripe. This is used @@ -696,12 +758,17 @@ private constructor( this.paymentProviderId = paymentProviderId } - fun portalUrl(portalUrl: String) = portalUrl(JsonField.of(portalUrl)) + fun portalUrl(portalUrl: String?) = portalUrl(JsonField.ofNullable(portalUrl)) + + fun portalUrl(portalUrl: Optional) = portalUrl(portalUrl.orElse(null)) fun portalUrl(portalUrl: JsonField) = apply { this.portalUrl = portalUrl } - fun shippingAddress(shippingAddress: ShippingAddress) = - shippingAddress(JsonField.of(shippingAddress)) + fun shippingAddress(shippingAddress: ShippingAddress?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress @@ -813,7 +880,115 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId) = taxId(JsonField.of(taxId)) + fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -937,15 +1112,22 @@ private constructor( */ fun timezone(timezone: JsonField) = apply { this.timezone = timezone } - fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration) = - accountingSyncConfiguration(JsonField.of(accountingSyncConfiguration)) + fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration?) = + accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) + + fun accountingSyncConfiguration( + accountingSyncConfiguration: Optional + ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) fun accountingSyncConfiguration( accountingSyncConfiguration: JsonField ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration) = - reportingConfiguration(JsonField.of(reportingConfiguration)) + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = + reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) fun reportingConfiguration(reportingConfiguration: JsonField) = apply { @@ -973,25 +1155,32 @@ private constructor( fun build(): Customer = Customer( - id, - additionalEmails.map { it.toImmutable() }, - autoCollection, - balance, - billingAddress, - createdAt, - currency, - email, - emailDelivery, - exemptFromAutomatedTax, - externalCustomerId, - metadata, - name, - paymentProvider, - paymentProviderId, - portalUrl, - shippingAddress, - taxId, - timezone, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(additionalEmails) { "`additionalEmails` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(balance) { "`balance` is required but was not set" }, + checkNotNull(billingAddress) { "`billingAddress` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(email) { "`email` is required but was not set" }, + checkNotNull(emailDelivery) { "`emailDelivery` is required but was not set" }, + checkNotNull(exemptFromAutomatedTax) { + "`exemptFromAutomatedTax` is required but was not set" + }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(paymentProvider) { "`paymentProvider` is required but was not set" }, + checkNotNull(paymentProviderId) { + "`paymentProviderId` is required but was not set" + }, + checkNotNull(portalUrl) { "`portalUrl` is required but was not set" }, + checkNotNull(shippingAddress) { "`shippingAddress` is required but was not set" }, + checkNotNull(taxId) { "`taxId` is required but was not set" }, + checkNotNull(timezone) { "`timezone` is required but was not set" }, accountingSyncConfiguration, reportingConfiguration, additionalProperties.toImmutable(), @@ -1037,17 +1226,19 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -1076,12 +1267,12 @@ private constructor( class Builder { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1095,27 +1286,39 @@ private constructor( additionalProperties = billingAddress.additionalProperties.toMutableMap() } - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) fun city(city: JsonField) = apply { this.city = city } - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) fun country(country: JsonField) = apply { this.country = country } - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) fun line1(line1: JsonField) = apply { this.line1 = line1 } - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) fun state(state: JsonField) = apply { this.state = state } @@ -1140,12 +1343,12 @@ private constructor( fun build(): BillingAddress = BillingAddress( - city, - country, - line1, - line2, - postalCode, - state, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(line1) { "`line1` is required but was not set" }, + checkNotNull(line2) { "`line2` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1362,17 +1565,19 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -1401,12 +1606,12 @@ private constructor( class Builder { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1420,27 +1625,39 @@ private constructor( additionalProperties = shippingAddress.additionalProperties.toMutableMap() } - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) fun city(city: JsonField) = apply { this.city = city } - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) fun country(country: JsonField) = apply { this.country = country } - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) fun line1(line1: JsonField) = apply { this.line1 = line1 } - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) fun state(state: JsonField) = apply { this.state = state } @@ -1465,12 +1682,12 @@ private constructor( fun build(): ShippingAddress = ShippingAddress( - city, - country, - line1, - line2, - postalCode, - state, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(line1) { "`line1` is required but was not set" }, + checkNotNull(line2) { "`line2` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1620,11 +1837,11 @@ private constructor( fun value(): String = value.getRequired("value") - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1650,9 +1867,9 @@ private constructor( class Builder { - private var country: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1696,9 +1913,9 @@ private constructor( fun build(): TaxId = TaxId( - country, - type, - value, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2726,9 +2943,9 @@ private constructor( @JsonProperty("accounting_providers") @ExcludeMissing - fun _accountingProviders() = accountingProviders + fun _accountingProviders(): JsonField> = accountingProviders - @JsonProperty("excluded") @ExcludeMissing fun _excluded() = excluded + @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded @JsonAnyGetter @ExcludeMissing @@ -2753,13 +2970,14 @@ private constructor( class Builder { - private var accountingProviders: JsonField> = JsonMissing.of() - private var excluded: JsonField = JsonMissing.of() + private var accountingProviders: JsonField>? = null + private var excluded: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { - accountingProviders = accountingSyncConfiguration.accountingProviders + accountingProviders = + accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } excluded = accountingSyncConfiguration.excluded additionalProperties = accountingSyncConfiguration.additionalProperties.toMutableMap() @@ -2770,9 +2988,22 @@ private constructor( fun accountingProviders(accountingProviders: JsonField>) = apply { - this.accountingProviders = accountingProviders + this.accountingProviders = accountingProviders.map { it.toMutableList() } } + fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { + accountingProviders = + (accountingProviders ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(accountingProvider) + } + } + fun excluded(excluded: Boolean) = excluded(JsonField.of(excluded)) fun excluded(excluded: JsonField) = apply { this.excluded = excluded } @@ -2798,8 +3029,11 @@ private constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( - accountingProviders.map { it.toImmutable() }, - excluded, + checkNotNull(accountingProviders) { + "`accountingProviders` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(excluded) { "`excluded` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2825,9 +3059,11 @@ private constructor( @JsonProperty("external_provider_id") @ExcludeMissing - fun _externalProviderId() = externalProviderId + fun _externalProviderId(): JsonField = externalProviderId - @JsonProperty("provider_type") @ExcludeMissing fun _providerType() = providerType + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType @JsonAnyGetter @ExcludeMissing @@ -2852,8 +3088,8 @@ private constructor( class Builder { - private var externalProviderId: JsonField = JsonMissing.of() - private var providerType: JsonField = JsonMissing.of() + private var externalProviderId: JsonField? = null + private var providerType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2863,8 +3099,11 @@ private constructor( additionalProperties = accountingProvider.additionalProperties.toMutableMap() } - fun externalProviderId(externalProviderId: String) = - externalProviderId(JsonField.of(externalProviderId)) + fun externalProviderId(externalProviderId: String?) = + externalProviderId(JsonField.ofNullable(externalProviderId)) + + fun externalProviderId(externalProviderId: Optional) = + externalProviderId(externalProviderId.orElse(null)) fun externalProviderId(externalProviderId: JsonField) = apply { this.externalProviderId = externalProviderId @@ -2901,8 +3140,10 @@ private constructor( fun build(): AccountingProvider = AccountingProvider( - externalProviderId, - providerType, + checkNotNull(externalProviderId) { + "`externalProviderId` is required but was not set" + }, + checkNotNull(providerType) { "`providerType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3013,7 +3254,7 @@ private constructor( fun exempt(): Boolean = exempt.getRequired("exempt") - @JsonProperty("exempt") @ExcludeMissing fun _exempt() = exempt + @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt @JsonAnyGetter @ExcludeMissing @@ -3037,7 +3278,7 @@ private constructor( class Builder { - private var exempt: JsonField = JsonMissing.of() + private var exempt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3070,7 +3311,10 @@ private constructor( } fun build(): ReportingConfiguration = - ReportingConfiguration(exempt, additionalProperties.toImmutable()) + ReportingConfiguration( + checkNotNull(exempt) { "`exempt` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt index 02e3c23c..962aa8db 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,10 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** + * Creates an immutable balance transaction that updates the customer's balance and returns back the + * newly created transaction. + */ class CustomerBalanceTransactionCreateParams constructor( private val customerId: String, @@ -36,12 +41,19 @@ constructor( /** An optional description that can be specified around this entry. */ fun description(): Optional = body.description() - fun _additionalHeaders(): Headers = additionalHeaders + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _type(): JsonField = body._type() + + /** An optional description that can be specified around this entry. */ + fun _description(): JsonField = body._description() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CustomerBalanceTransactionCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -59,25 +71,49 @@ constructor( class CustomerBalanceTransactionCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: String, - @JsonProperty("type") private val type: Type, - @JsonProperty("description") private val description: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("amount") fun amount(): String = amount + fun amount(): String = amount.getRequired("amount") + + fun type(): Type = type.getRequired("type") + + /** An optional description that can be specified around this entry. */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("type") fun type(): Type = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** An optional description that can be specified around this entry. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomerBalanceTransactionCreateBody = apply { + if (!validated) { + amount() + type() + description() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -87,9 +123,9 @@ constructor( class Builder { - private var amount: String? = null - private var type: Type? = null - private var description: String? = null + private var amount: JsonField? = null + private var type: JsonField? = null + private var description: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,16 +139,25 @@ constructor( customerBalanceTransactionCreateBody.additionalProperties.toMutableMap() } - fun amount(amount: String) = apply { this.amount = amount } + fun amount(amount: String) = amount(JsonField.of(amount)) + + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun type(type: Type) = type(JsonField.of(type)) - fun type(type: Type) = apply { this.type = type } + fun type(type: JsonField) = apply { this.type = type } /** An optional description that can be specified around this entry. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** An optional description that can be specified around this entry. */ fun description(description: Optional) = description(description.orElse(null)) + /** An optional description that can be specified around this entry. */ + fun description(description: JsonField) = apply { + this.description = description + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -190,14 +235,40 @@ constructor( fun amount(amount: String) = apply { body.amount(amount) } + fun amount(amount: JsonField) = apply { body.amount(amount) } + fun type(type: Type) = apply { body.type(type) } + fun type(type: JsonField) = apply { body.type(type) } + /** An optional description that can be specified around this entry. */ fun description(description: String?) = apply { body.description(description) } /** An optional description that can be specified around this entry. */ fun description(description: Optional) = description(description.orElse(null)) + /** An optional description that can be specified around this entry. */ + fun description(description: JsonField) = apply { body.description(description) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -296,25 +367,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CustomerBalanceTransactionCreateParams = CustomerBalanceTransactionCreateParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt index 0bf92cb5..446e3a3e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionCreateResponse.kt @@ -86,35 +86,43 @@ private constructor( fun type(): Type = type.getRequired("type") /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("action") @ExcludeMissing fun _action() = action + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The creation time of this transaction. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_note") @ExcludeMissing fun _creditNote() = creditNote + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** * The new value of the customer's balance prior to the transaction, in the customer's currency. */ - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("invoice") @ExcludeMissing fun _invoice() = invoice + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice /** * The original value of the customer's balance prior to the transaction, in the customer's * currency. */ - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -147,16 +155,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var action: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNote: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var invoice: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -199,12 +207,17 @@ private constructor( /** The creation time of this transaction. */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun creditNote(creditNote: CreditNote) = creditNote(JsonField.of(creditNote)) + fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) + + fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) fun creditNote(creditNote: JsonField) = apply { this.creditNote = creditNote } /** An optional description provided for manual customer balance adjustments. */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: Optional) = description(description.orElse(null)) /** An optional description provided for manual customer balance adjustments. */ fun description(description: JsonField) = apply { this.description = description } @@ -223,7 +236,9 @@ private constructor( this.endingBalance = endingBalance } - fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) + + fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) fun invoice(invoice: JsonField) = apply { this.invoice = invoice } @@ -267,16 +282,16 @@ private constructor( fun build(): CustomerBalanceTransactionCreateResponse = CustomerBalanceTransactionCreateResponse( - id, - action, - amount, - createdAt, - creditNote, - description, - endingBalance, - invoice, - startingBalance, - type, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(action) { "`action` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNote) { "`creditNote` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(invoice) { "`invoice` is required but was not set" }, + checkNotNull(startingBalance) { "`startingBalance` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -387,7 +402,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -411,7 +426,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -445,7 +460,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) + fun build(): CreditNote = + CreditNote( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -478,7 +497,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -502,7 +521,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -536,7 +555,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) + fun build(): Invoice = + Invoice( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt index eb971499..60559df1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListParams.kt @@ -10,6 +10,32 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * ## The customer balance + * + * The customer balance is an amount in the customer's currency, which Orb automatically applies to + * subsequent invoices. This balance can be adjusted manually via Orb's webapp on the customer + * details page. You can use this balance to provide a fixed mid-period credit to the customer. + * Commonly, this is done due to system downtime/SLA violation, or an adhoc adjustment discussed + * with the customer. + * + * If the balance is a positive value at the time of invoicing, it represents that the customer has + * credit that should be used to offset the amount due on the next issued invoice. In this case, Orb + * will automatically reduce the next invoice by the balance amount, and roll over any remaining + * balance if the invoice is fully discounted. + * + * If the balance is a negative value at the time of invoicing, Orb will increase the invoice's + * amount due with a positive adjustment, and reset the balance to 0. + * + * This endpoint retrieves all customer balance transactions in reverse chronological order for a + * single customer, providing a complete audit trail of all adjustments and invoice applications. + * + * ## Eligibility + * + * The customer balance can only be applied to invoices or adjusted manually if invoices are not + * synced to a separate invoicing provider. If a payment gateway such as Stripe is used, the balance + * will be applied to the invoice before forwarding payment to the gateway. + */ class CustomerBalanceTransactionListParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt index 913835ca..c9b0f689 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerBalanceTransactionListResponse.kt @@ -86,35 +86,43 @@ private constructor( fun type(): Type = type.getRequired("type") /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("action") @ExcludeMissing fun _action() = action + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The creation time of this transaction. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_note") @ExcludeMissing fun _creditNote() = creditNote + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description /** * The new value of the customer's balance prior to the transaction, in the customer's currency. */ - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("invoice") @ExcludeMissing fun _invoice() = invoice + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice /** * The original value of the customer's balance prior to the transaction, in the customer's * currency. */ - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -147,16 +155,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var action: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNote: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var invoice: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -199,12 +207,17 @@ private constructor( /** The creation time of this transaction. */ fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun creditNote(creditNote: CreditNote) = creditNote(JsonField.of(creditNote)) + fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) + + fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) fun creditNote(creditNote: JsonField) = apply { this.creditNote = creditNote } /** An optional description provided for manual customer balance adjustments. */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: Optional) = description(description.orElse(null)) /** An optional description provided for manual customer balance adjustments. */ fun description(description: JsonField) = apply { this.description = description } @@ -223,7 +236,9 @@ private constructor( this.endingBalance = endingBalance } - fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) + + fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) fun invoice(invoice: JsonField) = apply { this.invoice = invoice } @@ -267,16 +282,16 @@ private constructor( fun build(): CustomerBalanceTransactionListResponse = CustomerBalanceTransactionListResponse( - id, - action, - amount, - createdAt, - creditNote, - description, - endingBalance, - invoice, - startingBalance, - type, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(action) { "`action` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNote) { "`creditNote` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(invoice) { "`invoice` is required but was not set" }, + checkNotNull(startingBalance) { "`startingBalance` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -387,7 +402,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -411,7 +426,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -445,7 +460,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) + fun build(): CreditNote = + CreditNote( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -478,7 +497,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -502,7 +521,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -536,7 +555,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) + fun build(): Invoice = + Invoice( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt index 8e72a504..d5bf64e2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdParams.kt @@ -14,6 +14,114 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated by + * applying pricing information to the underlying usage (see the + * [subscription usage endpoint](fetch-subscription-usage.api.mdx) to fetch usage per metric, in + * usage units rather than a currency). + * + * This endpoint can be leveraged for internal tooling and to provide a more transparent billing + * experience for your end users: + * 1. Understand the cost breakdown per line item historically and in real-time for the current + * billing period. + * 2. Provide customer visibility into how different services are contributing to the overall + * invoice with a per-day timeseries (as compared to the + * [upcoming invoice](fetch-upcoming-invoice) resource, which represents a snapshot for the + * current period). + * 3. Assess how minimums and discounts affect your customers by teasing apart costs directly as a + * result of usage, as opposed to minimums and discounts at the plan and price level. + * 4. Gain insight into key customer health metrics, such as the percent utilization of the minimum + * committed spend. + * + * ## Fetching subscriptions + * + * By default, this endpoint fetches the currently active subscription for the customer, and returns + * cost information for the subscription's current billing period, broken down by each participating + * price. If there are no currently active subscriptions, this will instead default to the most + * recently active subscription or return an empty series if none are found. For example, if your + * plan charges for compute hours, job runs, and data syncs, then this endpoint would provide a + * daily breakdown of your customer's cost for each of those axes. + * + * If timeframe bounds are specified, Orb fetches all subscriptions that were active in that + * timeframe. If two subscriptions overlap on a single day, costs from each price will be summed, + * and prices for both subscriptions will be included in the breakdown. + * + * ## Prepaid plans + * + * For plans that include prices which deduct credits rather than accrue in-arrears charges in a + * billable currency, this endpoint will return the total deduction amount, in credits, for the + * specified timeframe. + * + * ## Cumulative subtotals and totals + * + * Since the subtotal and total must factor in any billing-period level discounts and minimums, it's + * most meaningful to consider costs relative to the start of the subscription's billing period. As + * a result, by default this endpoint returns cumulative totals since the beginning of the billing + * period. In particular, the `timeframe_start` of a returned timeframe window is _always_ the + * beginning of the billing period and `timeframe_end` is incremented one day at a time to build the + * result. + * + * A customer that uses a few API calls a day but has a minimum commitment might exhibit the + * following pattern for their subtotal and total in the first few days of the month. Here, we + * assume that each API call is $2.50, the customer's plan has a monthly minimum of $50 for this + * price, and that the subscription's billing period bounds are aligned to the first of the month: + * + * | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total (incl. commitment) | + * |-----------------|---------------|------------------|----------|--------------------------| + * | 2023-02-01 | 2023-02-02 | 9 | $22.50 | $50.00 | + * | 2023-02-01 | 2023-02-03 | 19 | $47.50 | $50.00 | + * | 2023-02-01 | 2023-02-04 | 20 | $50.00 | $50.00 | + * | 2023-02-01 | 2023-02-05 | 28 | $70.00 | $70.00 | + * | 2023-02-01 | 2023-02-06 | 36 | $90.00 | $90.00 | + * + * ### Periodic values + * + * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental + * day-by-day view of costs. In this case, there will always be a one-day difference between + * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top of + * the cumulative costs, calculated by taking the difference of each timeframe with the last. Note + * that in the above example, the `Total` value would be 0 for the second two data points, since the + * minimum commitment has not yet been hit and each day is not contributing anything to the total + * cost. + * + * ## Timeframe bounds + * + * For an active subscription, both timeframes should be specified in the request. If a subscription + * starts or ends within the timeframe, the response will only include windows where the + * subscription is active. If a subscription has ended, no timeframe bounds need to be specified and + * the response will default to the billing period when the subscription was last active. + * + * As noted above, `timeframe_start` for a given cumulative datapoint is always the beginning of the + * billing period, and `timeframe_end` is incremented one day at a time to construct the response. + * When a timeframe is passed in that is not aligned to the current subscription's billing period, + * the response will contain cumulative totals from multiple billing periods. + * + * Suppose the queried customer has a subscription aligned to the 15th of every month. If this + * endpoint is queried with the date range `2023-06-01` - `2023-07-01`, the first data point will + * represent about half a billing period's worth of costs, accounting for accruals from the start of + * the billing period and inclusive of the first day of the timeframe (`timeframe_start = 2023-05-15 + * 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) + * + * | datapoint index | timeframe_start | timeframe_end | + * |-----------------|-----------------|---------------| + * | 0 | 2023-05-15 | 2023-06-02 | + * | 1 | 2023-05-15 | 2023-06-03 | + * | 2 | ... | ... | + * | 3 | 2023-05-15 | 2023-06-14 | + * | 4 | 2023-06-15 | 2023-06-16 | + * | 5 | 2023-06-15 | 2023-06-17 | + * | 6 | ... | ... | + * | 7 | 2023-06-15 | 2023-07-01 | + * + * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). + * + * ### Matrix prices + * + * When a price uses matrix pricing, it's important to view costs grouped by those matrix + * dimensions. Orb will return `price_groups` with the `grouping_key` and `secondary_grouping_key` + * based on the matrix price definition, for each `grouping_value` and `secondary_grouping_value` + * available. + */ class CustomerCostListByExternalIdParams constructor( private val externalCustomerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt index ef215cf0..ed4307e0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListByExternalIdResponse.kt @@ -29,7 +29,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -53,21 +53,36 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from( customerCostListByExternalIdResponse: CustomerCostListByExternalIdResponse ) = apply { - data = customerCostListByExternalIdResponse.data + data = customerCostListByExternalIdResponse.data.map { it.toMutableList() } additionalProperties = customerCostListByExternalIdResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -90,7 +105,8 @@ private constructor( fun build(): CustomerCostListByExternalIdResponse = CustomerCostListByExternalIdResponse( - data.map { it.toImmutable() }, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -130,17 +146,23 @@ private constructor( /** Total costs for the timeframe, including any minimums and discounts. */ fun total(): String = total.getRequired("total") - @JsonProperty("per_price_costs") @ExcludeMissing fun _perPriceCosts() = perPriceCosts + @JsonProperty("per_price_costs") + @ExcludeMissing + fun _perPriceCosts(): JsonField> = perPriceCosts /** Total costs for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** Total costs for the timeframe, including any minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total @JsonAnyGetter @ExcludeMissing @@ -168,16 +190,16 @@ private constructor( class Builder { - private var perPriceCosts: JsonField> = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() + private var perPriceCosts: JsonField>? = null + private var subtotal: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var total: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - perPriceCosts = data.perPriceCosts + perPriceCosts = data.perPriceCosts.map { it.toMutableList() } subtotal = data.subtotal timeframeEnd = data.timeframeEnd timeframeStart = data.timeframeStart @@ -189,7 +211,20 @@ private constructor( perPriceCosts(JsonField.of(perPriceCosts)) fun perPriceCosts(perPriceCosts: JsonField>) = apply { - this.perPriceCosts = perPriceCosts + this.perPriceCosts = perPriceCosts.map { it.toMutableList() } + } + + fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { + perPriceCosts = + (perPriceCosts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(perPriceCost) + } } /** Total costs for the timeframe, excluding any minimums and discounts. */ @@ -239,11 +274,12 @@ private constructor( fun build(): Data = Data( - perPriceCosts.map { it.toImmutable() }, - subtotal, - timeframeEnd, - timeframeStart, - total, + checkNotNull(perPriceCosts) { "`perPriceCosts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -735,16 +771,16 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** Price's contributions for the timeframe, including minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total /** The price's quantity for the timeframe */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -771,9 +807,9 @@ private constructor( class Builder { - private var price: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() + private var price: JsonField? = null + private var subtotal: JsonField? = null + private var total: JsonField? = null private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1254,6 +1290,73 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = + price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = + price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * Price's contributions for the timeframe, excluding any minimums and discounts. */ @@ -1271,7 +1374,15 @@ private constructor( fun total(total: JsonField) = apply { this.total = total } /** The price's quantity for the timeframe */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** The price's quantity for the timeframe */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** The price's quantity for the timeframe */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun quantity(quantity: Optional) = + quantity(quantity.orElse(null) as Double?) /** The price's quantity for the timeframe */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -1300,9 +1411,9 @@ private constructor( fun build(): PerPriceCost = PerPriceCost( - price, - subtotal, - total, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, quantity, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt index 3a06cae2..a6e7a627 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListParams.kt @@ -14,6 +14,114 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint is used to fetch a day-by-day snapshot of a customer's costs in Orb, calculated by + * applying pricing information to the underlying usage (see the + * [subscription usage endpoint](fetch-subscription-usage.api.mdx) to fetch usage per metric, in + * usage units rather than a currency). + * + * This endpoint can be leveraged for internal tooling and to provide a more transparent billing + * experience for your end users: + * 1. Understand the cost breakdown per line item historically and in real-time for the current + * billing period. + * 2. Provide customer visibility into how different services are contributing to the overall + * invoice with a per-day timeseries (as compared to the + * [upcoming invoice](fetch-upcoming-invoice) resource, which represents a snapshot for the + * current period). + * 3. Assess how minimums and discounts affect your customers by teasing apart costs directly as a + * result of usage, as opposed to minimums and discounts at the plan and price level. + * 4. Gain insight into key customer health metrics, such as the percent utilization of the minimum + * committed spend. + * + * ## Fetching subscriptions + * + * By default, this endpoint fetches the currently active subscription for the customer, and returns + * cost information for the subscription's current billing period, broken down by each participating + * price. If there are no currently active subscriptions, this will instead default to the most + * recently active subscription or return an empty series if none are found. For example, if your + * plan charges for compute hours, job runs, and data syncs, then this endpoint would provide a + * daily breakdown of your customer's cost for each of those axes. + * + * If timeframe bounds are specified, Orb fetches all subscriptions that were active in that + * timeframe. If two subscriptions overlap on a single day, costs from each price will be summed, + * and prices for both subscriptions will be included in the breakdown. + * + * ## Prepaid plans + * + * For plans that include prices which deduct credits rather than accrue in-arrears charges in a + * billable currency, this endpoint will return the total deduction amount, in credits, for the + * specified timeframe. + * + * ## Cumulative subtotals and totals + * + * Since the subtotal and total must factor in any billing-period level discounts and minimums, it's + * most meaningful to consider costs relative to the start of the subscription's billing period. As + * a result, by default this endpoint returns cumulative totals since the beginning of the billing + * period. In particular, the `timeframe_start` of a returned timeframe window is _always_ the + * beginning of the billing period and `timeframe_end` is incremented one day at a time to build the + * result. + * + * A customer that uses a few API calls a day but has a minimum commitment might exhibit the + * following pattern for their subtotal and total in the first few days of the month. Here, we + * assume that each API call is $2.50, the customer's plan has a monthly minimum of $50 for this + * price, and that the subscription's billing period bounds are aligned to the first of the month: + * + * | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total (incl. commitment) | + * |-----------------|---------------|------------------|----------|--------------------------| + * | 2023-02-01 | 2023-02-02 | 9 | $22.50 | $50.00 | + * | 2023-02-01 | 2023-02-03 | 19 | $47.50 | $50.00 | + * | 2023-02-01 | 2023-02-04 | 20 | $50.00 | $50.00 | + * | 2023-02-01 | 2023-02-05 | 28 | $70.00 | $70.00 | + * | 2023-02-01 | 2023-02-06 | 36 | $90.00 | $90.00 | + * + * ### Periodic values + * + * When the query parameter `view_mode=periodic` is specified, Orb will return an incremental + * day-by-day view of costs. In this case, there will always be a one-day difference between + * `timeframe_start` and `timeframe_end` for the timeframes returned. This is a transform on top of + * the cumulative costs, calculated by taking the difference of each timeframe with the last. Note + * that in the above example, the `Total` value would be 0 for the second two data points, since the + * minimum commitment has not yet been hit and each day is not contributing anything to the total + * cost. + * + * ## Timeframe bounds + * + * For an active subscription, both timeframes should be specified in the request. If a subscription + * starts or ends within the timeframe, the response will only include windows where the + * subscription is active. If a subscription has ended, no timeframe bounds need to be specified and + * the response will default to the billing period when the subscription was last active. + * + * As noted above, `timeframe_start` for a given cumulative datapoint is always the beginning of the + * billing period, and `timeframe_end` is incremented one day at a time to construct the response. + * When a timeframe is passed in that is not aligned to the current subscription's billing period, + * the response will contain cumulative totals from multiple billing periods. + * + * Suppose the queried customer has a subscription aligned to the 15th of every month. If this + * endpoint is queried with the date range `2023-06-01` - `2023-07-01`, the first data point will + * represent about half a billing period's worth of costs, accounting for accruals from the start of + * the billing period and inclusive of the first day of the timeframe (`timeframe_start = 2023-05-15 + * 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) + * + * | datapoint index | timeframe_start | timeframe_end | + * |-----------------|-----------------|---------------| + * | 0 | 2023-05-15 | 2023-06-02 | + * | 1 | 2023-05-15 | 2023-06-03 | + * | 2 | ... | ... | + * | 3 | 2023-05-15 | 2023-06-14 | + * | 4 | 2023-06-15 | 2023-06-16 | + * | 5 | 2023-06-15 | 2023-06-17 | + * | 6 | ... | ... | + * | 7 | 2023-06-15 | 2023-07-01 | + * + * You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). + * + * ### Matrix prices + * + * When a price uses matrix pricing, it's important to view costs grouped by those matrix + * dimensions. Orb will return `price_groups` with the `grouping_key` and `secondary_grouping_key` + * based on the matrix price definition, for each `grouping_value` and `secondary_grouping_value` + * available. + */ class CustomerCostListParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt index 7e284d2f..4052e29a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCostListResponse.kt @@ -29,7 +29,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -53,18 +53,33 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(customerCostListResponse: CustomerCostListResponse) = apply { - data = customerCostListResponse.data + data = customerCostListResponse.data.map { it.toMutableList() } additionalProperties = customerCostListResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -87,7 +102,8 @@ private constructor( fun build(): CustomerCostListResponse = CustomerCostListResponse( - data.map { it.toImmutable() }, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -127,17 +143,23 @@ private constructor( /** Total costs for the timeframe, including any minimums and discounts. */ fun total(): String = total.getRequired("total") - @JsonProperty("per_price_costs") @ExcludeMissing fun _perPriceCosts() = perPriceCosts + @JsonProperty("per_price_costs") + @ExcludeMissing + fun _perPriceCosts(): JsonField> = perPriceCosts /** Total costs for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** Total costs for the timeframe, including any minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total @JsonAnyGetter @ExcludeMissing @@ -165,16 +187,16 @@ private constructor( class Builder { - private var perPriceCosts: JsonField> = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() + private var perPriceCosts: JsonField>? = null + private var subtotal: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var total: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - perPriceCosts = data.perPriceCosts + perPriceCosts = data.perPriceCosts.map { it.toMutableList() } subtotal = data.subtotal timeframeEnd = data.timeframeEnd timeframeStart = data.timeframeStart @@ -186,7 +208,20 @@ private constructor( perPriceCosts(JsonField.of(perPriceCosts)) fun perPriceCosts(perPriceCosts: JsonField>) = apply { - this.perPriceCosts = perPriceCosts + this.perPriceCosts = perPriceCosts.map { it.toMutableList() } + } + + fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { + perPriceCosts = + (perPriceCosts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(perPriceCost) + } } /** Total costs for the timeframe, excluding any minimums and discounts. */ @@ -236,11 +271,12 @@ private constructor( fun build(): Data = Data( - perPriceCosts.map { it.toImmutable() }, - subtotal, - timeframeEnd, - timeframeStart, - total, + checkNotNull(perPriceCosts) { "`perPriceCosts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -732,16 +768,16 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** Price's contributions for the timeframe, including minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total /** The price's quantity for the timeframe */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -768,9 +804,9 @@ private constructor( class Builder { - private var price: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() + private var price: JsonField? = null + private var subtotal: JsonField? = null + private var total: JsonField? = null private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1251,6 +1287,73 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = + price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = + price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * Price's contributions for the timeframe, excluding any minimums and discounts. */ @@ -1268,7 +1371,15 @@ private constructor( fun total(total: JsonField) = apply { this.total = total } /** The price's quantity for the timeframe */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** The price's quantity for the timeframe */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** The price's quantity for the timeframe */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun quantity(quantity: Optional) = + quantity(quantity.orElse(null) as Double?) /** The price's quantity for the timeframe */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -1297,9 +1408,9 @@ private constructor( fun build(): PerPriceCost = PerPriceCost( - price, - subtotal, - total, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, quantity, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt index b119dfab..9eab1a6f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreateParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,18 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This operation is used to create an Orb customer, who is party to the core billing relationship. + * See [Customer](../guides/concepts#customer) for an overview of the customer resource. + * + * This endpoint is critical in the following Orb functionality: + * - Automated charges can be configured by setting `payment_provider` and `payment_provider_id` to + * automatically issue invoices + * - [Customer ID Aliases](../guides/events-and-metrics/customer-aliases) can be configured by + * setting `external_customer_id` + * - [Timezone localization](../guides/product-catalog/timezones.md) can be configured on a + * per-customer basis by setting the `timezone` parameter + */ class CustomerCreateParams constructor( private val body: CustomerCreateBody, @@ -219,64 +232,476 @@ constructor( */ fun timezone(): Optional = body.timezone() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + fun _email(): JsonField = body._email() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The full name of the customer */ + fun _name(): JsonField = body._name() + + fun _accountingSyncConfiguration(): JsonField = + body._accountingSyncConfiguration() + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun _additionalEmails(): JsonField> = body._additionalEmails() + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a saved + * payment method, if available. This parameter defaults to `True` when a payment provider is + * provided on customer creation. + */ + fun _autoCollection(): JsonField = body._autoCollection() + + fun _billingAddress(): JsonField = body._billingAddress() + + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun _currency(): JsonField = body._currency() + + fun _emailDelivery(): JsonField = body._emailDelivery() + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier in + * your system. + */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode, the connection must first be configured in the Orb webapp. + */ + fun _paymentProvider(): JsonField = body._paymentProvider() + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + fun _paymentProviderId(): JsonField = body._paymentProviderId() + + fun _reportingConfiguration(): JsonField = + body._reportingConfiguration() + + fun _shippingAddress(): JsonField = body._shippingAddress() + + fun _taxConfiguration(): JsonField = body._taxConfiguration() + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to the + * headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun _taxId(): JsonField = body._taxId() + + /** + * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. This + * defaults to your account's timezone if not set. This cannot be changed after customer + * creation. + */ + fun _timezone(): JsonField = body._timezone() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CustomerCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @JvmSynthetic internal fun getQueryParams(): QueryParams = additionalQueryParams - @NoAutoDetect - class CustomerCreateBody - @JsonCreator - internal constructor( - @JsonProperty("email") private val email: String, - @JsonProperty("name") private val name: String, - @JsonProperty("accounting_sync_configuration") - private val accountingSyncConfiguration: AccountingSyncConfiguration?, - @JsonProperty("additional_emails") private val additionalEmails: List?, - @JsonProperty("auto_collection") private val autoCollection: Boolean?, - @JsonProperty("billing_address") private val billingAddress: BillingAddress?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("email_delivery") private val emailDelivery: Boolean?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("payment_provider") private val paymentProvider: PaymentProvider?, - @JsonProperty("payment_provider_id") private val paymentProviderId: String?, - @JsonProperty("reporting_configuration") - private val reportingConfiguration: ReportingConfiguration?, - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress?, - @JsonProperty("tax_configuration") private val taxConfiguration: TaxConfiguration?, - @JsonProperty("tax_id") private val taxId: TaxId?, - @JsonProperty("timezone") private val timezone: String?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @NoAutoDetect + class CustomerCreateBody + @JsonCreator + internal constructor( + @JsonProperty("email") + @ExcludeMissing + private val email: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("accounting_sync_configuration") + @ExcludeMissing + private val accountingSyncConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("additional_emails") + @ExcludeMissing + private val additionalEmails: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + private val billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("email_delivery") + @ExcludeMissing + private val emailDelivery: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + private val paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + private val paymentProviderId: JsonField = JsonMissing.of(), + @JsonProperty("reporting_configuration") + @ExcludeMissing + private val reportingConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("tax_configuration") + @ExcludeMissing + private val taxConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("tax_id") + @ExcludeMissing + private val taxId: JsonField = JsonMissing.of(), + @JsonProperty("timezone") + @ExcludeMissing + private val timezone: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + fun email(): String = email.getRequired("email") + + /** The full name of the customer */ + fun name(): String = name.getRequired("name") + + fun accountingSyncConfiguration(): Optional = + Optional.ofNullable( + accountingSyncConfiguration.getNullable("accounting_sync_configuration") + ) + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(): Optional> = + Optional.ofNullable(additionalEmails.getNullable("additional_emails")) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun billingAddress(): Optional = + Optional.ofNullable(billingAddress.getNullable("billing_address")) + + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + fun emailDelivery(): Optional = + Optional.ofNullable(emailDelivery.getNullable("email_delivery")) + + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier + * in your system. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(): Optional = + Optional.ofNullable(paymentProvider.getNullable("payment_provider")) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(): Optional = + Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) + + fun reportingConfiguration(): Optional = + Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) + + fun shippingAddress(): Optional = + Optional.ofNullable(shippingAddress.getNullable("shipping_address")) + + fun taxConfiguration(): Optional = + Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + + /** + * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. + * This defaults to your account's timezone if not set. This cannot be changed after + * customer creation. + */ + fun timezone(): Optional = Optional.ofNullable(timezone.getNullable("timezone")) /** * A valid customer email, to be used for notifications. When Orb triggers payment through a * payment gateway, this email will be used for any automatically issued receipts. */ - @JsonProperty("email") fun email(): String = email + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email /** The full name of the customer */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("accounting_sync_configuration") - fun accountingSyncConfiguration(): Optional = - Optional.ofNullable(accountingSyncConfiguration) + @ExcludeMissing + fun _accountingSyncConfiguration(): JsonField = + accountingSyncConfiguration /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. */ @JsonProperty("additional_emails") - fun additionalEmails(): Optional> = Optional.ofNullable(additionalEmails) + @ExcludeMissing + fun _additionalEmails(): JsonField> = additionalEmails /** * Used to determine if invoices for this customer will automatically attempt to charge a @@ -284,19 +709,22 @@ constructor( * provider is provided on customer creation. */ @JsonProperty("auto_collection") - fun autoCollection(): Optional = Optional.ofNullable(autoCollection) + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_address") - fun billingAddress(): Optional = Optional.ofNullable(billingAddress) + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at * creation time, will be set at subscription creation time. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonProperty("email_delivery") - fun emailDelivery(): Optional = Optional.ofNullable(emailDelivery) + @ExcludeMissing + fun _emailDelivery(): JsonField = emailDelivery /** * An optional user-defined ID for this customer resource, used throughout the system as an @@ -304,38 +732,43 @@ constructor( * in your system. */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode, the connection must first be configured in the Orb webapp. */ @JsonProperty("payment_provider") - fun paymentProvider(): Optional = Optional.ofNullable(paymentProvider) + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider /** * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ @JsonProperty("payment_provider_id") - fun paymentProviderId(): Optional = Optional.ofNullable(paymentProviderId) + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId @JsonProperty("reporting_configuration") - fun reportingConfiguration(): Optional = - Optional.ofNullable(reportingConfiguration) + @ExcludeMissing + fun _reportingConfiguration(): JsonField = reportingConfiguration @JsonProperty("shipping_address") - fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress) + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress @JsonProperty("tax_configuration") - fun taxConfiguration(): Optional = Optional.ofNullable(taxConfiguration) + @ExcludeMissing + fun _taxConfiguration(): JsonField = taxConfiguration /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -443,19 +876,44 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("tax_id") fun taxId(): Optional = Optional.ofNullable(taxId) + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. * This defaults to your account's timezone if not set. This cannot be changed after * customer creation. */ - @JsonProperty("timezone") fun timezone(): Optional = Optional.ofNullable(timezone) + @JsonProperty("timezone") @ExcludeMissing fun _timezone(): JsonField = timezone @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomerCreateBody = apply { + if (!validated) { + email() + name() + accountingSyncConfiguration().map { it.validate() } + additionalEmails() + autoCollection() + billingAddress().map { it.validate() } + currency() + emailDelivery() + externalCustomerId() + metadata().map { it.validate() } + paymentProvider() + paymentProviderId() + reportingConfiguration().map { it.validate() } + shippingAddress().map { it.validate() } + taxConfiguration() + taxId().map { it.validate() } + timezone() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -465,23 +923,24 @@ constructor( class Builder { - private var email: String? = null - private var name: String? = null - private var accountingSyncConfiguration: AccountingSyncConfiguration? = null - private var additionalEmails: MutableList? = null - private var autoCollection: Boolean? = null - private var billingAddress: BillingAddress? = null - private var currency: String? = null - private var emailDelivery: Boolean? = null - private var externalCustomerId: String? = null - private var metadata: Metadata? = null - private var paymentProvider: PaymentProvider? = null - private var paymentProviderId: String? = null - private var reportingConfiguration: ReportingConfiguration? = null - private var shippingAddress: ShippingAddress? = null - private var taxConfiguration: TaxConfiguration? = null - private var taxId: TaxId? = null - private var timezone: String? = null + private var email: JsonField? = null + private var name: JsonField? = null + private var accountingSyncConfiguration: JsonField = + JsonMissing.of() + private var additionalEmails: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() + private var billingAddress: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var emailDelivery: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var paymentProvider: JsonField = JsonMissing.of() + private var paymentProviderId: JsonField = JsonMissing.of() + private var reportingConfiguration: JsonField = JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var taxConfiguration: JsonField = JsonMissing.of() + private var taxId: JsonField = JsonMissing.of() + private var timezone: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -489,7 +948,7 @@ constructor( email = customerCreateBody.email name = customerCreateBody.name accountingSyncConfiguration = customerCreateBody.accountingSyncConfiguration - additionalEmails = customerCreateBody.additionalEmails?.toMutableList() + additionalEmails = customerCreateBody.additionalEmails.map { it.toMutableList() } autoCollection = customerCreateBody.autoCollection billingAddress = customerCreateBody.billingAddress currency = customerCreateBody.currency @@ -511,26 +970,39 @@ constructor( * through a payment gateway, this email will be used for any automatically issued * receipts. */ - fun email(email: String) = apply { this.email = email } + fun email(email: String) = email(JsonField.of(email)) + + /** + * A valid customer email, to be used for notifications. When Orb triggers payment + * through a payment gateway, this email will be used for any automatically issued + * receipts. + */ + fun email(email: JsonField) = apply { this.email = email } + + /** The full name of the customer */ + fun name(name: String) = name(JsonField.of(name)) /** The full name of the customer */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun accountingSyncConfiguration( accountingSyncConfiguration: AccountingSyncConfiguration? - ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) fun accountingSyncConfiguration( accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + /** * Additional email addresses for this customer. If populated, these email addresses * will be CC'd for customer communications. */ - fun additionalEmails(additionalEmails: List?) = apply { - this.additionalEmails = additionalEmails?.toMutableList() - } + fun additionalEmails(additionalEmails: List?) = + additionalEmails(JsonField.ofNullable(additionalEmails)) /** * Additional email addresses for this customer. If populated, these email addresses @@ -539,13 +1011,29 @@ constructor( fun additionalEmails(additionalEmails: Optional>) = additionalEmails(additionalEmails.orElse(null)) + /** + * Additional email addresses for this customer. If populated, these email addresses + * will be CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + this.additionalEmails = additionalEmails.map { it.toMutableList() } + } + /** * Additional email addresses for this customer. If populated, these email addresses * will be CC'd for customer communications. */ fun addAdditionalEmail(additionalEmail: String) = apply { additionalEmails = - (additionalEmails ?: mutableListOf()).apply { add(additionalEmail) } + (additionalEmails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(additionalEmail) + } } /** @@ -553,9 +1041,8 @@ constructor( * a saved payment method, if available. This parameter defaults to `True` when a * payment provider is provided on customer creation. */ - fun autoCollection(autoCollection: Boolean?) = apply { - this.autoCollection = autoCollection - } + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) /** * Used to determine if invoices for this customer will automatically attempt to charge @@ -573,18 +1060,30 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) - fun billingAddress(billingAddress: BillingAddress?) = apply { - this.billingAddress = billingAddress + /** + * Used to determine if invoices for this customer will automatically attempt to charge + * a saved payment method, if available. This parameter defaults to `True` when a + * payment provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection } + fun billingAddress(billingAddress: BillingAddress?) = + billingAddress(JsonField.ofNullable(billingAddress)) + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = billingAddress + } + /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set * at creation time, will be set at subscription creation time. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set @@ -592,9 +1091,14 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) - fun emailDelivery(emailDelivery: Boolean?) = apply { - this.emailDelivery = emailDelivery - } + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set + * at creation time, will be set at subscription creation time. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun emailDelivery(emailDelivery: Boolean?) = + emailDelivery(JsonField.ofNullable(emailDelivery)) fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) @@ -602,14 +1106,17 @@ constructor( fun emailDelivery(emailDelivery: Optional) = emailDelivery(emailDelivery.orElse(null) as Boolean?) + fun emailDelivery(emailDelivery: JsonField) = apply { + this.emailDelivery = emailDelivery + } + /** * An optional user-defined ID for this customer resource, used throughout the system as * an alias for this Customer. Use this field to identify a customer by an existing * identifier in your system. */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * An optional user-defined ID for this customer resource, used throughout the system as @@ -619,12 +1126,21 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * An optional user-defined ID for this customer resource, used throughout the system as + * an alias for this Customer. Use this field to identify a customer by an existing + * identifier in your system. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -633,13 +1149,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * This is used for creating charges or invoices in an external system via Orb. When not * in test mode, the connection must first be configured in the Orb webapp. */ - fun paymentProvider(paymentProvider: PaymentProvider?) = apply { - this.paymentProvider = paymentProvider - } + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) /** * This is used for creating charges or invoices in an external system via Orb. When not @@ -648,54 +1170,184 @@ constructor( fun paymentProvider(paymentProvider: Optional) = paymentProvider(paymentProvider.orElse(null)) + /** + * This is used for creating charges or invoices in an external system via Orb. When not + * in test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + /** * The ID of this customer in an external payments solution, such as Stripe. This is * used for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: String?) = apply { - this.paymentProviderId = paymentProviderId - } + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is + * used for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) /** * The ID of this customer in an external payments solution, such as Stripe. This is * used for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - this.reportingConfiguration = reportingConfiguration - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - this.shippingAddress = shippingAddress - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - this.taxConfiguration = taxConfiguration - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration( - newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration - ) = apply { - this.taxConfiguration = - TaxConfiguration.ofNewAvalaraTaxConfiguration(newAvalaraTaxConfiguration) - } - - fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = - apply { - this.taxConfiguration = - TaxConfiguration.ofNewTaxJarConfiguration(newTaxJarConfiguration) - } + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = + reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + this.reportingConfiguration = reportingConfiguration + } + + fun shippingAddress(shippingAddress: ShippingAddress?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + fun taxConfiguration(taxConfiguration: TaxConfiguration?) = + taxConfiguration(JsonField.ofNullable(taxConfiguration)) + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + this.taxConfiguration = taxConfiguration + } + + fun taxConfiguration( + newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration + ) = + taxConfiguration( + TaxConfiguration.ofNewAvalaraTaxConfiguration(newAvalaraTaxConfiguration) + ) + + fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = + taxConfiguration(TaxConfiguration.ofNewTaxJarConfiguration(newTaxJarConfiguration)) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added + * to the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -803,7 +1455,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { this.taxId = taxId } + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -911,14 +1563,14 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } /** * A timezone identifier from the IANA timezone database, such as * `"America/Los_Angeles"`. This defaults to your account's timezone if not set. This * cannot be changed after customer creation. */ - fun timezone(timezone: String?) = apply { this.timezone = timezone } + fun timezone(timezone: String?) = timezone(JsonField.ofNullable(timezone)) /** * A timezone identifier from the IANA timezone database, such as @@ -927,6 +1579,13 @@ constructor( */ fun timezone(timezone: Optional) = timezone(timezone.orElse(null)) + /** + * A timezone identifier from the IANA timezone database, such as + * `"America/Los_Angeles"`. This defaults to your account's timezone if not set. This + * cannot be changed after customer creation. + */ + fun timezone(timezone: JsonField) = apply { this.timezone = timezone } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -951,7 +1610,7 @@ constructor( checkNotNull(email) { "`email` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, accountingSyncConfiguration, - additionalEmails?.toImmutable(), + (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, billingAddress, currency, @@ -1014,9 +1673,18 @@ constructor( */ fun email(email: String) = apply { body.email(email) } + /** + * A valid customer email, to be used for notifications. When Orb triggers payment through a + * payment gateway, this email will be used for any automatically issued receipts. + */ + fun email(email: JsonField) = apply { body.email(email) } + /** The full name of the customer */ fun name(name: String) = apply { body.name(name) } + /** The full name of the customer */ + fun name(name: JsonField) = apply { body.name(name) } + fun accountingSyncConfiguration(accountingSyncConfiguration: AccountingSyncConfiguration?) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) @@ -1026,6 +1694,10 @@ constructor( accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } + /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. @@ -1041,6 +1713,14 @@ constructor( fun additionalEmails(additionalEmails: Optional>) = additionalEmails(additionalEmails.orElse(null)) + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + body.additionalEmails(additionalEmails) + } + /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. @@ -1072,6 +1752,15 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + fun billingAddress(billingAddress: BillingAddress?) = apply { body.billingAddress(billingAddress) } @@ -1079,6 +1768,10 @@ constructor( fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) + fun billingAddress(billingAddress: JsonField) = apply { + body.billingAddress(billingAddress) + } + /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at * creation time, will be set at subscription creation time. @@ -1091,6 +1784,12 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + fun emailDelivery(emailDelivery: Boolean?) = apply { body.emailDelivery(emailDelivery) } fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) @@ -1099,6 +1798,10 @@ constructor( fun emailDelivery(emailDelivery: Optional) = emailDelivery(emailDelivery.orElse(null) as Boolean?) + fun emailDelivery(emailDelivery: JsonField) = apply { + body.emailDelivery(emailDelivery) + } + /** * An optional user-defined ID for this customer resource, used throughout the system as an * alias for this Customer. Use this field to identify a customer by an existing identifier @@ -1116,6 +1819,15 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * An optional user-defined ID for this customer resource, used throughout the system as an + * alias for this Customer. Use this field to identify a customer by an existing identifier + * in your system. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -1130,6 +1842,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode, the connection must first be configured in the Orb webapp. @@ -1145,6 +1864,14 @@ constructor( fun paymentProvider(paymentProvider: Optional) = paymentProvider(paymentProvider.orElse(null)) + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode, the connection must first be configured in the Orb webapp. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + body.paymentProvider(paymentProvider) + } + /** * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. @@ -1157,38 +1884,167 @@ constructor( * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - body.shippingAddress(shippingAddress) - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration( - newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration - ) = apply { body.taxConfiguration(newAvalaraTaxConfiguration) } - - fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = - apply { - body.taxConfiguration(newTaxJarConfiguration) - } + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + body.paymentProviderId(paymentProviderId) + } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { + body.reportingConfiguration(reportingConfiguration) + } + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + body.reportingConfiguration(reportingConfiguration) + } + + fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + body.shippingAddress(shippingAddress) + } + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + body.shippingAddress(shippingAddress) + } + + fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { + body.taxConfiguration(taxConfiguration) + } + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + body.taxConfiguration(taxConfiguration) + } + + fun taxConfiguration( + newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration + ) = apply { body.taxConfiguration(newAvalaraTaxConfiguration) } + + fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = + apply { + body.taxConfiguration(newTaxJarConfiguration) + } + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1296,7 +2152,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1404,7 +2260,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } /** * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. @@ -1420,6 +2276,32 @@ constructor( */ fun timezone(timezone: Optional) = timezone(timezone.orElse(null)) + /** + * A timezone identifier from the IANA timezone database, such as `"America/Los_Angeles"`. + * This defaults to your account's timezone if not set. This cannot be changed after + * customer creation. + */ + fun timezone(timezone: JsonField) = apply { body.timezone(timezone) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -1518,25 +2400,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CustomerCreateParams = CustomerCreateParams( body.build(), @@ -1550,22 +2413,40 @@ constructor( @JsonCreator private constructor( @JsonProperty("accounting_providers") - private val accountingProviders: List?, - @JsonProperty("excluded") private val excluded: Boolean?, + @ExcludeMissing + private val accountingProviders: JsonField> = JsonMissing.of(), + @JsonProperty("excluded") + @ExcludeMissing + private val excluded: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("accounting_providers") fun accountingProviders(): Optional> = - Optional.ofNullable(accountingProviders) + Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) + + fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) + + @JsonProperty("accounting_providers") + @ExcludeMissing + fun _accountingProviders(): JsonField> = accountingProviders - @JsonProperty("excluded") fun excluded(): Optional = Optional.ofNullable(excluded) + @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountingSyncConfiguration = apply { + if (!validated) { + accountingProviders().map { it.forEach { it.validate() } } + excluded() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1575,38 +2456,52 @@ constructor( class Builder { - private var accountingProviders: MutableList? = null - private var excluded: Boolean? = null + private var accountingProviders: JsonField>? = null + private var excluded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { accountingProviders = - accountingSyncConfiguration.accountingProviders?.toMutableList() + accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } excluded = accountingSyncConfiguration.excluded additionalProperties = accountingSyncConfiguration.additionalProperties.toMutableMap() } - fun accountingProviders(accountingProviders: List?) = apply { - this.accountingProviders = accountingProviders?.toMutableList() - } + fun accountingProviders(accountingProviders: List?) = + accountingProviders(JsonField.ofNullable(accountingProviders)) fun accountingProviders(accountingProviders: Optional>) = accountingProviders(accountingProviders.orElse(null)) + fun accountingProviders(accountingProviders: JsonField>) = + apply { + this.accountingProviders = accountingProviders.map { it.toMutableList() } + } + fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { accountingProviders = - (accountingProviders ?: mutableListOf()).apply { add(accountingProvider) } + (accountingProviders ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(accountingProvider) + } } - fun excluded(excluded: Boolean?) = apply { this.excluded = excluded } + fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) + fun excluded(excluded: JsonField) = apply { this.excluded = excluded } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1628,7 +2523,7 @@ constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( - accountingProviders?.toImmutable(), + (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, excluded, additionalProperties.toImmutable(), ) @@ -1638,21 +2533,43 @@ constructor( class AccountingProvider @JsonCreator private constructor( - @JsonProperty("external_provider_id") private val externalProviderId: String, - @JsonProperty("provider_type") private val providerType: String, + @JsonProperty("external_provider_id") + @ExcludeMissing + private val externalProviderId: JsonField = JsonMissing.of(), + @JsonProperty("provider_type") + @ExcludeMissing + private val providerType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun externalProviderId(): String = + externalProviderId.getRequired("external_provider_id") + + fun providerType(): String = providerType.getRequired("provider_type") + @JsonProperty("external_provider_id") - fun externalProviderId(): String = externalProviderId + @ExcludeMissing + fun _externalProviderId(): JsonField = externalProviderId - @JsonProperty("provider_type") fun providerType(): String = providerType + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountingProvider = apply { + if (!validated) { + externalProviderId() + providerType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1662,8 +2579,8 @@ constructor( class Builder { - private var externalProviderId: String? = null - private var providerType: String? = null + private var externalProviderId: JsonField? = null + private var providerType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1673,11 +2590,18 @@ constructor( additionalProperties = accountingProvider.additionalProperties.toMutableMap() } - fun externalProviderId(externalProviderId: String) = apply { + fun externalProviderId(externalProviderId: String) = + externalProviderId(JsonField.of(externalProviderId)) + + fun externalProviderId(externalProviderId: JsonField) = apply { this.externalProviderId = externalProviderId } - fun providerType(providerType: String) = apply { this.providerType = providerType } + fun providerType(providerType: String) = providerType(JsonField.of(providerType)) + + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1751,33 +2675,73 @@ constructor( class BillingAddress @JsonCreator private constructor( - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("line1") private val line1: String?, - @JsonProperty("line2") private val line2: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") + @ExcludeMissing + private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") + @ExcludeMissing + private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("city") fun city(): Optional = Optional.ofNullable(city) + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) + + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) + + fun postalCode(): Optional = + Optional.ofNullable(postalCode.getNullable("postal_code")) - @JsonProperty("country") fun country(): Optional = Optional.ofNullable(country) + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("line1") fun line1(): Optional = Optional.ofNullable(line1) + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("line2") fun line2(): Optional = Optional.ofNullable(line2) + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 @JsonProperty("postal_code") - fun postalCode(): Optional = Optional.ofNullable(postalCode) + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") fun state(): Optional = Optional.ofNullable(state) + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingAddress = apply { + if (!validated) { + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1787,12 +2751,12 @@ constructor( class Builder { - private var city: String? = null - private var country: String? = null - private var line1: String? = null - private var line2: String? = null - private var postalCode: String? = null - private var state: String? = null + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1806,30 +2770,42 @@ constructor( additionalProperties = billingAddress.additionalProperties.toMutableMap() } - fun city(city: String?) = apply { this.city = city } + fun city(city: String?) = city(JsonField.ofNullable(city)) fun city(city: Optional) = city(city.orElse(null)) - fun country(country: String?) = apply { this.country = country } + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) fun country(country: Optional) = country(country.orElse(null)) - fun line1(line1: String?) = apply { this.line1 = line1 } + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) fun line1(line1: Optional) = line1(line1.orElse(null)) - fun line2(line2: String?) = apply { this.line2 = line2 } + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) fun line2(line2: Optional) = line2(line2.orElse(null)) - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - fun state(state: String?) = apply { this.state = state } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) fun state(state: Optional) = state(state.orElse(null)) + fun state(state: JsonField) = apply { this.state = state } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1896,6 +2872,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2030,17 +3014,30 @@ constructor( class ReportingConfiguration @JsonCreator private constructor( - @JsonProperty("exempt") private val exempt: Boolean, + @JsonProperty("exempt") + @ExcludeMissing + private val exempt: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("exempt") fun exempt(): Boolean = exempt + fun exempt(): Boolean = exempt.getRequired("exempt") + + @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReportingConfiguration = apply { + if (!validated) { + exempt() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2050,7 +3047,7 @@ constructor( class Builder { - private var exempt: Boolean? = null + private var exempt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2059,7 +3056,9 @@ constructor( additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() } - fun exempt(exempt: Boolean) = apply { this.exempt = exempt } + fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) + + fun exempt(exempt: JsonField) = apply { this.exempt = exempt } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2109,33 +3108,73 @@ constructor( class ShippingAddress @JsonCreator private constructor( - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("line1") private val line1: String?, - @JsonProperty("line2") private val line2: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") + @ExcludeMissing + private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") + @ExcludeMissing + private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("city") fun city(): Optional = Optional.ofNullable(city) + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - @JsonProperty("country") fun country(): Optional = Optional.ofNullable(country) + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - @JsonProperty("line1") fun line1(): Optional = Optional.ofNullable(line1) + fun postalCode(): Optional = + Optional.ofNullable(postalCode.getNullable("postal_code")) - @JsonProperty("line2") fun line2(): Optional = Optional.ofNullable(line2) + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) + + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 @JsonProperty("postal_code") - fun postalCode(): Optional = Optional.ofNullable(postalCode) + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") fun state(): Optional = Optional.ofNullable(state) + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ShippingAddress = apply { + if (!validated) { + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2145,12 +3184,12 @@ constructor( class Builder { - private var city: String? = null - private var country: String? = null - private var line1: String? = null - private var line2: String? = null - private var postalCode: String? = null - private var state: String? = null + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2164,30 +3203,42 @@ constructor( additionalProperties = shippingAddress.additionalProperties.toMutableMap() } - fun city(city: String?) = apply { this.city = city } + fun city(city: String?) = city(JsonField.ofNullable(city)) fun city(city: Optional) = city(city.orElse(null)) - fun country(country: String?) = apply { this.country = country } + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) fun country(country: Optional) = country(country.orElse(null)) - fun line1(line1: String?) = apply { this.line1 = line1 } + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) fun line1(line1: Optional) = line1(line1.orElse(null)) - fun line2(line2: String?) = apply { this.line2 = line2 } + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) fun line2(line2: Optional) = line2(line2.orElse(null)) - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - fun state(state: String?) = apply { this.state = state } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) fun state(state: Optional) = state(state.orElse(null)) + fun state(state: JsonField) = apply { this.state = state } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2246,6 +3297,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newAvalaraTaxConfiguration(): Optional = Optional.ofNullable(newAvalaraTaxConfiguration) @@ -2274,6 +3327,17 @@ constructor( } } + fun validate(): TaxConfiguration = apply { + if (!validated) { + if (newAvalaraTaxConfiguration == null && newTaxJarConfiguration == null) { + throw OrbInvalidDataException("Unknown TaxConfiguration: $_json") + } + newAvalaraTaxConfiguration?.validate() + newTaxJarConfiguration?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2328,14 +3392,23 @@ constructor( when (taxProvider) { "avalara" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return TaxConfiguration(newAvalaraTaxConfiguration = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return TaxConfiguration( + newAvalaraTaxConfiguration = it, + _json = json + ) + } } "taxjar" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return TaxConfiguration(newTaxJarConfiguration = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return TaxConfiguration(newTaxJarConfiguration = it, _json = json) + } } } @@ -2365,24 +3438,53 @@ constructor( class NewAvalaraTaxConfiguration @JsonCreator private constructor( - @JsonProperty("tax_exempt") private val taxExempt: Boolean, - @JsonProperty("tax_provider") private val taxProvider: TaxProvider, - @JsonProperty("tax_exemption_code") private val taxExemptionCode: String?, + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), + @JsonProperty("tax_exemption_code") + @ExcludeMissing + private val taxExemptionCode: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("tax_exempt") fun taxExempt(): Boolean = taxExempt + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - @JsonProperty("tax_provider") fun taxProvider(): TaxProvider = taxProvider + fun taxExemptionCode(): Optional = + Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) + + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider @JsonProperty("tax_exemption_code") - fun taxExemptionCode(): Optional = Optional.ofNullable(taxExemptionCode) + @ExcludeMissing + fun _taxExemptionCode(): JsonField = taxExemptionCode @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAvalaraTaxConfiguration = apply { + if (!validated) { + taxExempt() + taxProvider() + taxExemptionCode() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2392,9 +3494,9 @@ constructor( class Builder { - private var taxExempt: Boolean? = null - private var taxProvider: TaxProvider? = null - private var taxExemptionCode: String? = null + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null + private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2406,17 +3508,26 @@ constructor( newAvalaraTaxConfiguration.additionalProperties.toMutableMap() } - fun taxExempt(taxExempt: Boolean) = apply { this.taxExempt = taxExempt } + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - fun taxProvider(taxProvider: TaxProvider) = apply { this.taxProvider = taxProvider } + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxExemptionCode(taxExemptionCode: String?) = apply { - this.taxExemptionCode = taxExemptionCode + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider } + fun taxExemptionCode(taxExemptionCode: String?) = + taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) + fun taxExemptionCode(taxExemptionCode: Optional) = taxExemptionCode(taxExemptionCode.orElse(null)) + fun taxExemptionCode(taxExemptionCode: JsonField) = apply { + this.taxExemptionCode = taxExemptionCode + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2521,20 +3632,42 @@ constructor( class NewTaxJarConfiguration @JsonCreator private constructor( - @JsonProperty("tax_exempt") private val taxExempt: Boolean, - @JsonProperty("tax_provider") private val taxProvider: TaxProvider, + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("tax_exempt") fun taxExempt(): Boolean = taxExempt + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt - @JsonProperty("tax_provider") fun taxProvider(): TaxProvider = taxProvider + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewTaxJarConfiguration = apply { + if (!validated) { + taxExempt() + taxProvider() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2544,8 +3677,8 @@ constructor( class Builder { - private var taxExempt: Boolean? = null - private var taxProvider: TaxProvider? = null + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2556,9 +3689,15 @@ constructor( newTaxJarConfiguration.additionalProperties.toMutableMap() } - fun taxExempt(taxExempt: Boolean) = apply { this.taxExempt = taxExempt } + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = apply { this.taxProvider = taxProvider } + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2770,23 +3909,44 @@ constructor( class TaxId @JsonCreator private constructor( - @JsonProperty("country") private val country: Country, - @JsonProperty("type") private val type: Type, - @JsonProperty("value") private val value: String, + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("country") fun country(): Country = country + fun country(): Country = country.getRequired("country") + + fun type(): Type = type.getRequired("type") + + fun value(): String = value.getRequired("value") - @JsonProperty("type") fun type(): Type = type + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("value") fun value(): String = value + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TaxId = apply { + if (!validated) { + country() + type() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2796,9 +3956,9 @@ constructor( class Builder { - private var country: Country? = null - private var type: Type? = null - private var value: String? = null + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2809,11 +3969,17 @@ constructor( additionalProperties = taxId.additionalProperties.toMutableMap() } - fun country(country: Country) = apply { this.country = country } + fun country(country: Country) = country(JsonField.of(country)) + + fun country(country: JsonField) = apply { this.country = country } + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } - fun type(type: Type) = apply { this.type = type } + fun value(value: String) = value(JsonField.of(value)) - fun value(value: String) = apply { this.value = value } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt index b614b8e3..6273e81b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -32,6 +33,108 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint allows you to create a new ledger entry for a specified customer's balance. This + * can be used to increment balance, deduct credits, and change the expiry date of existing credits. + * + * ## Effects of adding a ledger entry + * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a + * credit block that represents the changes (i.e. balance changes or transfers). + * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned + * in the [View Credits Ledger](fetch-customer-credits-ledger) response as well as serialized in + * the response to this request. In the case of deductions without a specified block, multiple + * ledger entries may be created if the deduction spans credit blocks. + * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the + * credits (based on `amount` and `per_unit_cost_basis`). + * + * ## Adding credits + * + * Adding credits is done by creating an entry of type `increment`. This requires the caller to + * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also + * recommends specifying a description to assist with auditing. When adding credits, the caller can + * also specify a cost basis per-credit, to indicate how much in USD a customer paid for a single + * credit in a block. This can later be used for revenue recognition. + * + * The following snippet illustrates a sample request body to increment credits which will expire in + * January of 2022. + * + * ```json + * { + * "entry_type": "increment", + * "amount": 100, + * "expiry_date": "2022-12-28", + * "per_unit_cost_basis": "0.20", + * "description": "Purchased 100 credits" + * } + * ``` + * + * Note that by default, Orb will always first increment any _negative_ balance in existing blocks + * before adding the remaining amount to the desired credit block. + * + * ### Invoicing for credits + * + * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you + * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for + * the customer for the credits pre-purchase. Note that you _must_ provide the + * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the + * cost basis with the number of credit units added. + * + * ## Deducting Credits + * + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb + * matches the algorithm for automatic deductions for determining which credit blocks to decrement + * from. In the case that the deduction leads to multiple ledger entries, the response from this + * endpoint will be the final deduction. Orb also optionally allows specifying a description to + * assist with auditing. + * + * The following snippet illustrates a sample request body to decrement credits. + * + * ```json + * { + * "entry_type": "decrement", + * "amount": 20, + * "description": "Removing excess credits" + * } + * ``` + * + * ## Changing credits expiry + * + * If you'd like to change when existing credits expire, you should create a ledger entry of type + * `expiration_change`. For this entry, the required parameter `expiry_date` identifies the + * _originating_ block, and the required parameter `target_expiry_date` identifies when the + * transferred credits should now expire. A new credit block will be created with expiry date + * `target_expiry_date`, with the same cost basis data as the original credit block, if present. + * + * Note that the balance of the block with the given `expiry_date` must be at least equal to the + * desired transfer amount determined by the `amount` parameter. + * + * The following snippet illustrates a sample request body to extend the expiration date of credits + * by one year: + * ```json + * { + * "entry_type": "expiration_change", + * "amount": 10, + * "expiry_date": "2022-12-28", + * "block_id": "UiUhFWeLHPrBY4Ad", + * "target_expiry_date": "2023-12-28", + * "description": "Extending credit validity" + * } + * ``` + * + * ## Voiding credits + * + * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, + * `block_id` is required to identify the block, and `amount` indicates how many credits to void, up + * to the block's initial balance. Pass in a `void_reason` of `refund` if the void is due to a + * refund. + * + * ## Amendment + * + * If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. + * For this entry, `block_id` is required to identify the block that was originally decremented + * from, and `amount` indicates how many credits to return to the customer, up to the block's + * initial balance. + */ class CustomerCreditLedgerCreateEntryByExternalIdParams constructor( private val externalCustomerId: String, @@ -611,15 +714,33 @@ constructor( class AddIncrementCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("effective_date") private val effectiveDate: OffsetDateTime?, - @JsonProperty("expiry_date") private val expiryDate: OffsetDateTime?, - @JsonProperty("invoice_settings") private val invoiceSettings: InvoiceSettings?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("per_unit_cost_basis") private val perUnitCostBasis: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_settings") + @ExcludeMissing + private val invoiceSettings: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -628,15 +749,72 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * An ISO 8601 format date that denotes when this credit balance should become available for + * use. + */ + fun effectiveDate(): Optional = + Optional.ofNullable(effectiveDate.getNullable("effective_date")) + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as the + * calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(): Optional = + Optional.ofNullable(invoiceSettings.getNullable("invoice_settings")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * Can only be specified when entry_type=increment. How much, in the customer's currency, a + * customer paid for a single credit in this block + */ + fun perUnitCostBasis(): Optional = + Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -644,18 +822,21 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * An ISO 8601 format date that denotes when this credit balance should become available for * use. */ @JsonProperty("effective_date") - fun effectiveDate(): Optional = Optional.ofNullable(effectiveDate) + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** An ISO 8601 format date that denotes when this credit balance should expire. */ @JsonProperty("expiry_date") - fun expiryDate(): Optional = Optional.ofNullable(expiryDate) + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate /** * Passing `invoice_settings` automatically generates an invoice for the newly added @@ -663,26 +844,45 @@ constructor( * calculation of the invoice total is done on that basis. */ @JsonProperty("invoice_settings") - fun invoiceSettings(): Optional = Optional.ofNullable(invoiceSettings) + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * Can only be specified when entry_type=increment. How much, in the customer's currency, a * customer paid for a single credit in this block */ @JsonProperty("per_unit_cost_basis") - fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis) + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + entryType() + currency() + description() + effectiveDate() + expiryDate() + invoiceSettings().map { it.validate() } + metadata().map { it.validate() } + perUnitCostBasis() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -692,15 +892,15 @@ constructor( class Builder { - private var amount: Double? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var effectiveDate: OffsetDateTime? = null - private var expiryDate: OffsetDateTime? = null - private var invoiceSettings: InvoiceSettings? = null - private var metadata: Metadata? = null - private var perUnitCostBasis: String? = null + private var amount: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var expiryDate: JsonField = JsonMissing.of() + private var invoiceSettings: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var perUnitCostBasis: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -725,15 +925,23 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -741,12 +949,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -755,13 +969,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * An ISO 8601 format date that denotes when this credit balance should become available * for use. */ - fun effectiveDate(effectiveDate: OffsetDateTime?) = apply { - this.effectiveDate = effectiveDate - } + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) /** * An ISO 8601 format date that denotes when this credit balance should become available @@ -770,21 +992,34 @@ constructor( fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.orElse(null)) + /** + * An ISO 8601 format date that denotes when this credit balance should become available + * for use. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: OffsetDateTime?) = apply { this.expiryDate = expiryDate } + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) /** An ISO 8601 format date that denotes when this credit balance should expire. */ fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as * the calculation of the invoice total is done on that basis. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings?) = apply { - this.invoiceSettings = invoiceSettings - } + fun invoiceSettings(invoiceSettings: InvoiceSettings?) = + invoiceSettings(JsonField.ofNullable(invoiceSettings)) /** * Passing `invoice_settings` automatically generates an invoice for the newly added @@ -794,12 +1029,21 @@ constructor( fun invoiceSettings(invoiceSettings: Optional) = invoiceSettings(invoiceSettings.orElse(null)) + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as + * the calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { + this.invoiceSettings = invoiceSettings + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -808,13 +1052,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * Can only be specified when entry_type=increment. How much, in the customer's * currency, a customer paid for a single credit in this block */ - fun perUnitCostBasis(perUnitCostBasis: String?) = apply { - this.perUnitCostBasis = perUnitCostBasis - } + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) /** * Can only be specified when entry_type=increment. How much, in the customer's @@ -823,6 +1073,14 @@ constructor( fun perUnitCostBasis(perUnitCostBasis: Optional) = perUnitCostBasis(perUnitCostBasis.orElse(null)) + /** + * Can only be specified when entry_type=increment. How much, in the customer's + * currency, a customer paid for a single credit in this block + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -917,11 +1175,18 @@ constructor( class InvoiceSettings @JsonCreator private constructor( - @JsonProperty("auto_collection") private val autoCollection: Boolean, - @JsonProperty("net_terms") private val netTerms: Long, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonProperty("require_successful_payment") - private val requireSuccessfulPayment: Boolean?, + @ExcludeMissing + private val requireSuccessfulPayment: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -930,29 +1195,67 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") fun autoCollection(): Boolean = autoCollection + fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") /** * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") fun netTerms(): Long = netTerms + fun netTerms(): Long = netTerms.getRequired("net_terms") /** An optional memo to display on the invoice. */ - @JsonProperty("memo") fun memo(): Optional = Optional.ofNullable(memo) + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. */ - @JsonProperty("require_successful_payment") fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment) + Optional.ofNullable( + requireSuccessfulPayment.getNullable("require_successful_payment") + ) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** An optional memo to display on the invoice. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * If true, the new credit block will require that the corresponding invoice is paid + * before it can be drawn down from. + */ + @JsonProperty("require_successful_payment") + @ExcludeMissing + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceSettings = apply { + if (!validated) { + autoCollection() + netTerms() + memo() + requireSuccessfulPayment() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -962,10 +1265,10 @@ constructor( class Builder { - private var autoCollection: Boolean? = null - private var netTerms: Long? = null - private var memo: String? = null - private var requireSuccessfulPayment: Boolean? = null + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null + private var memo: JsonField = JsonMissing.of() + private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -981,7 +1284,14 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's * saved payment method. */ - fun autoCollection(autoCollection: Boolean) = apply { + fun autoCollection(autoCollection: Boolean) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Whether the credits purchase invoice should auto collect with the customer's + * saved payment method. + */ + fun autoCollection(autoCollection: JsonField) = apply { this.autoCollection = autoCollection } @@ -990,36 +1300,38 @@ constructor( * date for the invoice. If you intend the invoice to be due on issue, set this * to 0. */ - fun netTerms(netTerms: Long) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * The net terms determines the difference between the invoice date and the issue + * date for the invoice. If you intend the invoice to be due on issue, set this + * to 0. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** An optional memo to display on the invoice. */ fun memo(memo: Optional) = memo(memo.orElse(null)) - /** - * If true, the new credit block will require that the corresponding invoice is paid - * before it can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean?) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } + /** An optional memo to display on the invoice. */ + fun memo(memo: JsonField) = apply { this.memo = memo } /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. */ fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(requireSuccessfulPayment as Boolean?) + requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun requireSuccessfulPayment(requireSuccessfulPayment: Optional) = - requireSuccessfulPayment(requireSuccessfulPayment.orElse(null) as Boolean?) + fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { + this.requireSuccessfulPayment = requireSuccessfulPayment + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1090,6 +1402,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1170,11 +1490,21 @@ constructor( class AddDecrementCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1183,15 +1513,46 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + fun entryType(): EntryType = entryType.getRequired("entry_type") /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1199,19 +1560,33 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + entryType() + currency() + description() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1221,11 +1596,11 @@ constructor( class Builder { - private var amount: Double? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var amount: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1246,15 +1621,23 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1262,12 +1645,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1276,12 +1665,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1290,6 +1688,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1388,6 +1793,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1468,47 +1881,113 @@ constructor( class AddExpirationChangeCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("expiry_date") private val expiryDate: OffsetDateTime?, - @JsonProperty("target_expiry_date") private val targetExpiryDate: LocalDate, - @JsonProperty("amount") private val amount: Double?, - @JsonProperty("block_id") private val blockId: String?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("target_expiry_date") + @ExcludeMissing + private val targetExpiryDate: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + /** + * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting when + * credits transferred (as part of a partial block expiration) should expire. + */ + fun targetExpiryDate(): LocalDate = targetExpiryDate.getRequired("target_expiry_date") + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("block_id")) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType /** An ISO 8601 format date that identifies the origination credit block to expire */ @JsonProperty("expiry_date") - fun expiryDate(): Optional = Optional.ofNullable(expiryDate) + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate /** * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting when * credits transferred (as part of a partial block expiration) should expire. */ - @JsonProperty("target_expiry_date") fun targetExpiryDate(): LocalDate = targetExpiryDate + @JsonProperty("target_expiry_date") + @ExcludeMissing + fun _targetExpiryDate(): JsonField = targetExpiryDate /** * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Optional = Optional.ofNullable(amount) + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The ID of the block affected by an expiration_change, used to differentiate between * multiple blocks with the same `expiry_date`. */ - @JsonProperty("block_id") fun blockId(): Optional = Optional.ofNullable(blockId) + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1516,19 +1995,36 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { + if (!validated) { + entryType() + expiryDate() + targetExpiryDate() + amount() + blockId() + currency() + description() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1538,14 +2034,14 @@ constructor( class Builder { - private var entryType: EntryType? = null - private var expiryDate: OffsetDateTime? = null - private var targetExpiryDate: LocalDate? = null - private var amount: Double? = null - private var blockId: String? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var entryType: JsonField? = null + private var expiryDate: JsonField? = null + private var targetExpiryDate: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var blockId: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1567,20 +2063,35 @@ constructor( .toMutableMap() } - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** An ISO 8601 format date that identifies the origination credit block to expire */ - fun expiryDate(expiryDate: OffsetDateTime?) = apply { this.expiryDate = expiryDate } + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) /** An ISO 8601 format date that identifies the origination credit block to expire */ fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + /** + * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting + * when credits transferred (as part of a partial block expiration) should expire. + */ + fun targetExpiryDate(targetExpiryDate: LocalDate) = + targetExpiryDate(JsonField.of(targetExpiryDate)) + /** * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting * when credits transferred (as part of a partial block expiration) should expire. */ - fun targetExpiryDate(targetExpiryDate: LocalDate) = apply { + fun targetExpiryDate(targetExpiryDate: JsonField) = apply { this.targetExpiryDate = targetExpiryDate } @@ -1588,7 +2099,7 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double?) = apply { this.amount = amount } + fun amount(amount: Double?) = amount(JsonField.ofNullable(amount)) /** * The number of credits to effect. Note that this is required for increment, decrement, @@ -1603,11 +2114,17 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun amount(amount: Optional) = amount(amount.orElse(null) as Double?) + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + /** * The ID of the block affected by an expiration_change, used to differentiate between * multiple blocks with the same `expiry_date`. */ - fun blockId(blockId: String?) = apply { this.blockId = blockId } + fun blockId(blockId: String?) = blockId(JsonField.ofNullable(blockId)) /** * The ID of the block affected by an expiration_change, used to differentiate between @@ -1615,11 +2132,17 @@ constructor( */ fun blockId(blockId: Optional) = blockId(blockId.orElse(null)) + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1627,12 +2150,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1641,12 +2170,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1655,6 +2193,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1677,7 +2222,7 @@ constructor( fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = AddExpirationChangeCreditLedgerEntryRequestParams( checkNotNull(entryType) { "`entryType` is required but was not set" }, - expiryDate, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, checkNotNull(targetExpiryDate) { "`targetExpiryDate` is required but was not set" }, @@ -1758,6 +2303,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1838,13 +2391,27 @@ constructor( class AddVoidCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("block_id") private val blockId: String, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("void_reason") private val voidReason: VoidReason?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("void_reason") + @ExcludeMissing + private val voidReason: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1853,18 +2420,56 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") /** The ID of the block to void. */ - @JsonProperty("block_id") fun blockId(): String = blockId + fun blockId(): String = blockId.getRequired("block_id") - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + fun entryType(): EntryType = entryType.getRequired("entry_type") /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(): Optional = + Optional.ofNullable(voidReason.getNullable("void_reason")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The ID of the block to void. */ + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1872,23 +2477,40 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Can only be specified when `entry_type=void`. The reason for the void. */ @JsonProperty("void_reason") - fun voidReason(): Optional = Optional.ofNullable(voidReason) + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + blockId() + entryType() + currency() + description() + metadata().map { it.validate() } + voidReason() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1898,13 +2520,13 @@ constructor( class Builder { - private var amount: Double? = null - private var blockId: String? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null - private var voidReason: VoidReason? = null + private var amount: JsonField? = null + private var blockId: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var voidReason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1926,18 +2548,29 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** The ID of the block to void. */ - fun blockId(blockId: String) = apply { this.blockId = blockId } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** The ID of the block to void. */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1945,12 +2578,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1959,12 +2598,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1973,12 +2621,24 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: VoidReason?) = apply { this.voidReason = voidReason } + fun voidReason(voidReason: VoidReason?) = voidReason(JsonField.ofNullable(voidReason)) /** Can only be specified when `entry_type=void`. The reason for the void. */ fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(voidReason: JsonField) = apply { + this.voidReason = voidReason + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2079,6 +2739,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2210,12 +2878,24 @@ constructor( class AddAmendmentCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("block_id") private val blockId: String, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2224,18 +2904,52 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement or * void operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") + + /** The ID of the block to reverse a decrement from. */ + fun blockId(): String = blockId.getRequired("block_id") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement or + * void operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The ID of the block to reverse a decrement from. */ - @JsonProperty("block_id") fun blockId(): String = blockId + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -2243,19 +2957,34 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + blockId() + entryType() + currency() + description() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2265,12 +2994,12 @@ constructor( class Builder { - private var amount: Double? = null - private var blockId: String? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var amount: JsonField? = null + private var blockId: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2292,18 +3021,29 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement * or void operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement + * or void operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** The ID of the block to reverse a decrement from. */ - fun blockId(blockId: String) = apply { this.blockId = blockId } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** The ID of the block to reverse a decrement from. */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -2311,12 +3051,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -2325,12 +3071,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -2339,6 +3094,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2438,6 +3200,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt index aeba2f02..3389f9a5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryByExternalIdResponse.kt @@ -453,38 +453,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -520,19 +534,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -581,7 +595,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -652,19 +668,23 @@ private constructor( fun build(): IncrementLedgerEntry = IncrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -694,13 +714,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -726,9 +748,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -743,14 +765,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -780,9 +809,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -824,11 +855,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -853,8 +884,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -868,8 +899,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -899,8 +933,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1225,44 +1261,58 @@ private constructor( fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("event_id") @ExcludeMissing fun _eventId() = eventId + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId() = invoiceId + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing @@ -1301,19 +1351,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var eventId: JsonField = JsonMissing.of() private var invoiceId: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1368,7 +1418,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -1418,15 +1470,21 @@ private constructor( this.startingBalance = startingBalance } - fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) + + fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) + fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) + + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) fun priceId(priceId: JsonField) = apply { this.priceId = priceId } @@ -1451,19 +1509,23 @@ private constructor( fun build(): DecrementLedgerEntry = DecrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, eventId, invoiceId, priceId, @@ -1496,13 +1558,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -1528,9 +1592,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1545,14 +1609,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -1582,9 +1653,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1626,11 +1699,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -1655,8 +1728,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1670,8 +1743,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -1701,8 +1777,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2018,42 +2096,56 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2090,20 +2182,20 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2154,7 +2246,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2197,8 +2291,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) + fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = + newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) + + fun newBlockExpiryDate(newBlockExpiryDate: Optional) = + newBlockExpiryDate(newBlockExpiryDate.orElse(null)) fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { this.newBlockExpiryDate = newBlockExpiryDate @@ -2232,20 +2329,26 @@ private constructor( fun build(): ExpirationChangeLedgerEntry = ExpirationChangeLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2275,13 +2378,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -2307,9 +2412,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2324,14 +2429,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -2361,9 +2473,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2405,11 +2519,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -2434,8 +2548,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2449,8 +2563,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -2480,8 +2597,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2791,38 +2910,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2858,19 +2991,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2920,7 +3053,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2991,19 +3126,23 @@ private constructor( fun build(): CreditBlockExpiryLedgerEntry = CreditBlockExpiryLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3033,13 +3172,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3065,9 +3206,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3082,14 +3223,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3119,9 +3267,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3163,11 +3313,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3192,8 +3342,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3207,8 +3357,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -3238,8 +3391,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3560,42 +3715,60 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -3633,21 +3806,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3698,7 +3871,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -3752,7 +3927,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -3777,21 +3954,25 @@ private constructor( fun build(): VoidLedgerEntry = VoidLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3821,13 +4002,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3853,9 +4036,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3870,14 +4053,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3907,9 +4097,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3951,11 +4143,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3980,8 +4172,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3995,8 +4187,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4026,8 +4221,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4354,46 +4551,64 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -4432,22 +4647,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4499,7 +4714,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -4560,7 +4777,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -4585,22 +4804,28 @@ private constructor( fun build(): VoidInitiatedLedgerEntry = VoidInitiatedLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4630,13 +4855,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -4662,9 +4889,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4679,14 +4906,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -4716,9 +4950,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4760,11 +4996,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -4789,8 +5025,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4804,8 +5040,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4835,8 +5074,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5146,38 +5387,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -5213,19 +5468,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5274,7 +5529,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -5345,19 +5602,23 @@ private constructor( fun build(): AmendmentLedgerEntry = AmendmentLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5387,13 +5648,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -5419,9 +5682,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5436,14 +5699,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -5473,9 +5743,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5517,11 +5789,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -5546,8 +5818,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5561,8 +5833,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -5592,8 +5867,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt index 23109e67..03cff2f9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -32,6 +33,108 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint allows you to create a new ledger entry for a specified customer's balance. This + * can be used to increment balance, deduct credits, and change the expiry date of existing credits. + * + * ## Effects of adding a ledger entry + * 1. After calling this endpoint, [Fetch Credit Balance](fetch-customer-credits) will return a + * credit block that represents the changes (i.e. balance changes or transfers). + * 2. A ledger entry will be added to the credits ledger for this customer, and therefore returned + * in the [View Credits Ledger](fetch-customer-credits-ledger) response as well as serialized in + * the response to this request. In the case of deductions without a specified block, multiple + * ledger entries may be created if the deduction spans credit blocks. + * 3. If `invoice_settings` is specified, an invoice will be created that reflects the cost of the + * credits (based on `amount` and `per_unit_cost_basis`). + * + * ## Adding credits + * + * Adding credits is done by creating an entry of type `increment`. This requires the caller to + * specify a number of credits as well as an optional expiry date in `YYYY-MM-DD` format. Orb also + * recommends specifying a description to assist with auditing. When adding credits, the caller can + * also specify a cost basis per-credit, to indicate how much in USD a customer paid for a single + * credit in a block. This can later be used for revenue recognition. + * + * The following snippet illustrates a sample request body to increment credits which will expire in + * January of 2022. + * + * ```json + * { + * "entry_type": "increment", + * "amount": 100, + * "expiry_date": "2022-12-28", + * "per_unit_cost_basis": "0.20", + * "description": "Purchased 100 credits" + * } + * ``` + * + * Note that by default, Orb will always first increment any _negative_ balance in existing blocks + * before adding the remaining amount to the desired credit block. + * + * ### Invoicing for credits + * + * By default, Orb manipulates the credit ledger but does not charge for credits. However, if you + * pass `invoice_settings` in the body of this request, Orb will also generate a one-off invoice for + * the customer for the credits pre-purchase. Note that you _must_ provide the + * `per_unit_cost_basis`, since the total charges on the invoice are calculated by multiplying the + * cost basis with the number of credit units added. + * + * ## Deducting Credits + * + * Orb allows you to deduct credits from a customer by creating an entry of type `decrement`. Orb + * matches the algorithm for automatic deductions for determining which credit blocks to decrement + * from. In the case that the deduction leads to multiple ledger entries, the response from this + * endpoint will be the final deduction. Orb also optionally allows specifying a description to + * assist with auditing. + * + * The following snippet illustrates a sample request body to decrement credits. + * + * ```json + * { + * "entry_type": "decrement", + * "amount": 20, + * "description": "Removing excess credits" + * } + * ``` + * + * ## Changing credits expiry + * + * If you'd like to change when existing credits expire, you should create a ledger entry of type + * `expiration_change`. For this entry, the required parameter `expiry_date` identifies the + * _originating_ block, and the required parameter `target_expiry_date` identifies when the + * transferred credits should now expire. A new credit block will be created with expiry date + * `target_expiry_date`, with the same cost basis data as the original credit block, if present. + * + * Note that the balance of the block with the given `expiry_date` must be at least equal to the + * desired transfer amount determined by the `amount` parameter. + * + * The following snippet illustrates a sample request body to extend the expiration date of credits + * by one year: + * ```json + * { + * "entry_type": "expiration_change", + * "amount": 10, + * "expiry_date": "2022-12-28", + * "block_id": "UiUhFWeLHPrBY4Ad", + * "target_expiry_date": "2023-12-28", + * "description": "Extending credit validity" + * } + * ``` + * + * ## Voiding credits + * + * If you'd like to void a credit block, create a ledger entry of type `void`. For this entry, + * `block_id` is required to identify the block, and `amount` indicates how many credits to void, up + * to the block's initial balance. Pass in a `void_reason` of `refund` if the void is due to a + * refund. + * + * ## Amendment + * + * If you'd like to undo a decrement on a credit block, create a ledger entry of type `amendment`. + * For this entry, `block_id` is required to identify the block that was originally decremented + * from, and `amount` indicates how many credits to return to the customer, up to the block's + * initial balance. + */ class CustomerCreditLedgerCreateEntryParams constructor( private val customerId: String, @@ -595,15 +698,33 @@ constructor( class AddIncrementCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("effective_date") private val effectiveDate: OffsetDateTime?, - @JsonProperty("expiry_date") private val expiryDate: OffsetDateTime?, - @JsonProperty("invoice_settings") private val invoiceSettings: InvoiceSettings?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("per_unit_cost_basis") private val perUnitCostBasis: String?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_settings") + @ExcludeMissing + private val invoiceSettings: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -612,15 +733,72 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * An ISO 8601 format date that denotes when this credit balance should become available for + * use. + */ + fun effectiveDate(): Optional = + Optional.ofNullable(effectiveDate.getNullable("effective_date")) + + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as the + * calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(): Optional = + Optional.ofNullable(invoiceSettings.getNullable("invoice_settings")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * Can only be specified when entry_type=increment. How much, in the customer's currency, a + * customer paid for a single credit in this block + */ + fun perUnitCostBasis(): Optional = + Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -628,18 +806,21 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * An ISO 8601 format date that denotes when this credit balance should become available for * use. */ @JsonProperty("effective_date") - fun effectiveDate(): Optional = Optional.ofNullable(effectiveDate) + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** An ISO 8601 format date that denotes when this credit balance should expire. */ @JsonProperty("expiry_date") - fun expiryDate(): Optional = Optional.ofNullable(expiryDate) + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate /** * Passing `invoice_settings` automatically generates an invoice for the newly added @@ -647,26 +828,45 @@ constructor( * calculation of the invoice total is done on that basis. */ @JsonProperty("invoice_settings") - fun invoiceSettings(): Optional = Optional.ofNullable(invoiceSettings) + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * Can only be specified when entry_type=increment. How much, in the customer's currency, a * customer paid for a single credit in this block */ @JsonProperty("per_unit_cost_basis") - fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis) + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddIncrementCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + entryType() + currency() + description() + effectiveDate() + expiryDate() + invoiceSettings().map { it.validate() } + metadata().map { it.validate() } + perUnitCostBasis() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -676,15 +876,15 @@ constructor( class Builder { - private var amount: Double? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var effectiveDate: OffsetDateTime? = null - private var expiryDate: OffsetDateTime? = null - private var invoiceSettings: InvoiceSettings? = null - private var metadata: Metadata? = null - private var perUnitCostBasis: String? = null + private var amount: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() + private var expiryDate: JsonField = JsonMissing.of() + private var invoiceSettings: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var perUnitCostBasis: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -709,15 +909,23 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -725,12 +933,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -739,13 +953,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * An ISO 8601 format date that denotes when this credit balance should become available * for use. */ - fun effectiveDate(effectiveDate: OffsetDateTime?) = apply { - this.effectiveDate = effectiveDate - } + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) /** * An ISO 8601 format date that denotes when this credit balance should become available @@ -754,21 +976,34 @@ constructor( fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.orElse(null)) + /** + * An ISO 8601 format date that denotes when this credit balance should become available + * for use. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + /** An ISO 8601 format date that denotes when this credit balance should expire. */ - fun expiryDate(expiryDate: OffsetDateTime?) = apply { this.expiryDate = expiryDate } + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) /** An ISO 8601 format date that denotes when this credit balance should expire. */ fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) + /** An ISO 8601 format date that denotes when this credit balance should expire. */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + /** * Passing `invoice_settings` automatically generates an invoice for the newly added * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as * the calculation of the invoice total is done on that basis. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings?) = apply { - this.invoiceSettings = invoiceSettings - } + fun invoiceSettings(invoiceSettings: InvoiceSettings?) = + invoiceSettings(JsonField.ofNullable(invoiceSettings)) /** * Passing `invoice_settings` automatically generates an invoice for the newly added @@ -778,12 +1013,21 @@ constructor( fun invoiceSettings(invoiceSettings: Optional) = invoiceSettings(invoiceSettings.orElse(null)) + /** + * Passing `invoice_settings` automatically generates an invoice for the newly added + * credits. If `invoice_settings` is passed, you must specify per_unit_cost_basis, as + * the calculation of the invoice total is done on that basis. + */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { + this.invoiceSettings = invoiceSettings + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -792,13 +1036,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * Can only be specified when entry_type=increment. How much, in the customer's * currency, a customer paid for a single credit in this block */ - fun perUnitCostBasis(perUnitCostBasis: String?) = apply { - this.perUnitCostBasis = perUnitCostBasis - } + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) /** * Can only be specified when entry_type=increment. How much, in the customer's @@ -807,6 +1057,14 @@ constructor( fun perUnitCostBasis(perUnitCostBasis: Optional) = perUnitCostBasis(perUnitCostBasis.orElse(null)) + /** + * Can only be specified when entry_type=increment. How much, in the customer's + * currency, a customer paid for a single credit in this block + */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + this.perUnitCostBasis = perUnitCostBasis + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -901,11 +1159,18 @@ constructor( class InvoiceSettings @JsonCreator private constructor( - @JsonProperty("auto_collection") private val autoCollection: Boolean, - @JsonProperty("net_terms") private val netTerms: Long, - @JsonProperty("memo") private val memo: String?, + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), @JsonProperty("require_successful_payment") - private val requireSuccessfulPayment: Boolean?, + @ExcludeMissing + private val requireSuccessfulPayment: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -914,29 +1179,67 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") fun autoCollection(): Boolean = autoCollection + fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") /** * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") fun netTerms(): Long = netTerms + fun netTerms(): Long = netTerms.getRequired("net_terms") /** An optional memo to display on the invoice. */ - @JsonProperty("memo") fun memo(): Optional = Optional.ofNullable(memo) + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. */ - @JsonProperty("require_successful_payment") fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment) + Optional.ofNullable( + requireSuccessfulPayment.getNullable("require_successful_payment") + ) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** An optional memo to display on the invoice. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * If true, the new credit block will require that the corresponding invoice is paid + * before it can be drawn down from. + */ + @JsonProperty("require_successful_payment") + @ExcludeMissing + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceSettings = apply { + if (!validated) { + autoCollection() + netTerms() + memo() + requireSuccessfulPayment() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -946,10 +1249,10 @@ constructor( class Builder { - private var autoCollection: Boolean? = null - private var netTerms: Long? = null - private var memo: String? = null - private var requireSuccessfulPayment: Boolean? = null + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null + private var memo: JsonField = JsonMissing.of() + private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -965,7 +1268,14 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's * saved payment method. */ - fun autoCollection(autoCollection: Boolean) = apply { + fun autoCollection(autoCollection: Boolean) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Whether the credits purchase invoice should auto collect with the customer's + * saved payment method. + */ + fun autoCollection(autoCollection: JsonField) = apply { this.autoCollection = autoCollection } @@ -974,36 +1284,38 @@ constructor( * date for the invoice. If you intend the invoice to be due on issue, set this * to 0. */ - fun netTerms(netTerms: Long) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * The net terms determines the difference between the invoice date and the issue + * date for the invoice. If you intend the invoice to be due on issue, set this + * to 0. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** An optional memo to display on the invoice. */ fun memo(memo: Optional) = memo(memo.orElse(null)) - /** - * If true, the new credit block will require that the corresponding invoice is paid - * before it can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean?) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } + /** An optional memo to display on the invoice. */ + fun memo(memo: JsonField) = apply { this.memo = memo } /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. */ fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(requireSuccessfulPayment as Boolean?) + requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) /** * If true, the new credit block will require that the corresponding invoice is paid * before it can be drawn down from. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun requireSuccessfulPayment(requireSuccessfulPayment: Optional) = - requireSuccessfulPayment(requireSuccessfulPayment.orElse(null) as Boolean?) + fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { + this.requireSuccessfulPayment = requireSuccessfulPayment + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1074,6 +1386,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1154,11 +1474,21 @@ constructor( class AddDecrementCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1167,15 +1497,46 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + fun entryType(): EntryType = entryType.getRequired("entry_type") /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1183,19 +1544,33 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddDecrementCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + entryType() + currency() + description() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1205,11 +1580,11 @@ constructor( class Builder { - private var amount: Double? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var amount: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1230,15 +1605,23 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1246,12 +1629,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1260,12 +1649,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1274,6 +1672,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1372,6 +1777,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1452,47 +1865,113 @@ constructor( class AddExpirationChangeCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("expiry_date") private val expiryDate: OffsetDateTime?, - @JsonProperty("target_expiry_date") private val targetExpiryDate: LocalDate, - @JsonProperty("amount") private val amount: Double?, - @JsonProperty("block_id") private val blockId: String?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("expiry_date") + @ExcludeMissing + private val expiryDate: JsonField = JsonMissing.of(), + @JsonProperty("target_expiry_date") + @ExcludeMissing + private val targetExpiryDate: JsonField = JsonMissing.of(), + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(): Optional = + Optional.ofNullable(expiryDate.getNullable("expiry_date")) + + /** + * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting when + * credits transferred (as part of a partial block expiration) should expire. + */ + fun targetExpiryDate(): LocalDate = targetExpiryDate.getRequired("target_expiry_date") + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(): Optional = Optional.ofNullable(amount.getNullable("amount")) + + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(): Optional = Optional.ofNullable(blockId.getNullable("block_id")) + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType /** An ISO 8601 format date that identifies the origination credit block to expire */ @JsonProperty("expiry_date") - fun expiryDate(): Optional = Optional.ofNullable(expiryDate) + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate /** * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting when * credits transferred (as part of a partial block expiration) should expire. */ - @JsonProperty("target_expiry_date") fun targetExpiryDate(): LocalDate = targetExpiryDate + @JsonProperty("target_expiry_date") + @ExcludeMissing + fun _targetExpiryDate(): JsonField = targetExpiryDate /** * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Optional = Optional.ofNullable(amount) + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The ID of the block affected by an expiration_change, used to differentiate between * multiple blocks with the same `expiry_date`. */ - @JsonProperty("block_id") fun blockId(): Optional = Optional.ofNullable(blockId) + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1500,19 +1979,36 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddExpirationChangeCreditLedgerEntryRequestParams = apply { + if (!validated) { + entryType() + expiryDate() + targetExpiryDate() + amount() + blockId() + currency() + description() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1522,14 +2018,14 @@ constructor( class Builder { - private var entryType: EntryType? = null - private var expiryDate: OffsetDateTime? = null - private var targetExpiryDate: LocalDate? = null - private var amount: Double? = null - private var blockId: String? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var entryType: JsonField? = null + private var expiryDate: JsonField? = null + private var targetExpiryDate: JsonField? = null + private var amount: JsonField = JsonMissing.of() + private var blockId: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1551,20 +2047,35 @@ constructor( .toMutableMap() } - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** An ISO 8601 format date that identifies the origination credit block to expire */ - fun expiryDate(expiryDate: OffsetDateTime?) = apply { this.expiryDate = expiryDate } + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) /** An ISO 8601 format date that identifies the origination credit block to expire */ fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) + /** An ISO 8601 format date that identifies the origination credit block to expire */ + fun expiryDate(expiryDate: JsonField) = apply { + this.expiryDate = expiryDate + } + + /** + * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting + * when credits transferred (as part of a partial block expiration) should expire. + */ + fun targetExpiryDate(targetExpiryDate: LocalDate) = + targetExpiryDate(JsonField.of(targetExpiryDate)) + /** * A future date (specified in YYYY-MM-DD format) used for expiration change, denoting * when credits transferred (as part of a partial block expiration) should expire. */ - fun targetExpiryDate(targetExpiryDate: LocalDate) = apply { + fun targetExpiryDate(targetExpiryDate: JsonField) = apply { this.targetExpiryDate = targetExpiryDate } @@ -1572,7 +2083,7 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double?) = apply { this.amount = amount } + fun amount(amount: Double?) = amount(JsonField.ofNullable(amount)) /** * The number of credits to effect. Note that this is required for increment, decrement, @@ -1587,11 +2098,17 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun amount(amount: Optional) = amount(amount.orElse(null) as Double?) + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + /** * The ID of the block affected by an expiration_change, used to differentiate between * multiple blocks with the same `expiry_date`. */ - fun blockId(blockId: String?) = apply { this.blockId = blockId } + fun blockId(blockId: String?) = blockId(JsonField.ofNullable(blockId)) /** * The ID of the block affected by an expiration_change, used to differentiate between @@ -1599,11 +2116,17 @@ constructor( */ fun blockId(blockId: Optional) = blockId(blockId.orElse(null)) + /** + * The ID of the block affected by an expiration_change, used to differentiate between + * multiple blocks with the same `expiry_date`. + */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1611,12 +2134,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1625,12 +2154,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1639,6 +2177,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1661,7 +2206,7 @@ constructor( fun build(): AddExpirationChangeCreditLedgerEntryRequestParams = AddExpirationChangeCreditLedgerEntryRequestParams( checkNotNull(entryType) { "`entryType` is required but was not set" }, - expiryDate, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, checkNotNull(targetExpiryDate) { "`targetExpiryDate` is required but was not set" }, @@ -1742,6 +2287,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1822,13 +2375,27 @@ constructor( class AddVoidCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("block_id") private val blockId: String, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("void_reason") private val voidReason: VoidReason?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("void_reason") + @ExcludeMissing + private val voidReason: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -1837,18 +2404,56 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") /** The ID of the block to void. */ - @JsonProperty("block_id") fun blockId(): String = blockId + fun blockId(): String = blockId.getRequired("block_id") - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + fun entryType(): EntryType = entryType.getRequired("entry_type") /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(): Optional = + Optional.ofNullable(voidReason.getNullable("void_reason")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount + + /** The ID of the block to void. */ + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId + + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1856,23 +2461,40 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** Can only be specified when `entry_type=void`. The reason for the void. */ @JsonProperty("void_reason") - fun voidReason(): Optional = Optional.ofNullable(voidReason) + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddVoidCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + blockId() + entryType() + currency() + description() + metadata().map { it.validate() } + voidReason() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1882,13 +2504,13 @@ constructor( class Builder { - private var amount: Double? = null - private var blockId: String? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null - private var voidReason: VoidReason? = null + private var amount: JsonField? = null + private var blockId: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var voidReason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1910,18 +2532,29 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement, * void, or undo operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement, + * void, or undo operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** The ID of the block to void. */ - fun blockId(blockId: String) = apply { this.blockId = blockId } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** The ID of the block to void. */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -1929,12 +2562,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -1943,12 +2582,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1957,12 +2605,24 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** Can only be specified when `entry_type=void`. The reason for the void. */ - fun voidReason(voidReason: VoidReason?) = apply { this.voidReason = voidReason } + fun voidReason(voidReason: VoidReason?) = voidReason(JsonField.ofNullable(voidReason)) /** Can only be specified when `entry_type=void`. The reason for the void. */ fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) + /** Can only be specified when `entry_type=void`. The reason for the void. */ + fun voidReason(voidReason: JsonField) = apply { + this.voidReason = voidReason + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2063,6 +2723,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2194,12 +2862,24 @@ constructor( class AddAmendmentCreditLedgerEntryRequestParams @JsonCreator private constructor( - @JsonProperty("amount") private val amount: Double, - @JsonProperty("block_id") private val blockId: String, - @JsonProperty("entry_type") private val entryType: EntryType, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("description") private val description: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("block_id") + @ExcludeMissing + private val blockId: JsonField = JsonMissing.of(), + @JsonProperty("entry_type") + @ExcludeMissing + private val entryType: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -2208,18 +2888,52 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement or * void operations. */ - @JsonProperty("amount") fun amount(): Double = amount + fun amount(): Double = amount.getRequired("amount") + + /** The ID of the block to reverse a decrement from. */ + fun blockId(): String = blockId.getRequired("block_id") + + fun entryType(): EntryType = entryType.getRequired("entry_type") + + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The number of credits to effect. Note that this is required for increment, decrement or + * void operations. + */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The ID of the block to reverse a decrement from. */ - @JsonProperty("block_id") fun blockId(): String = blockId + @JsonProperty("block_id") @ExcludeMissing fun _blockId(): JsonField = blockId - @JsonProperty("entry_type") fun entryType(): EntryType = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType /** * The currency or custom pricing unit to use for this ledger entry. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -2227,19 +2941,34 @@ constructor( * corrections as a result of an incident, etc. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddAmendmentCreditLedgerEntryRequestParams = apply { + if (!validated) { + amount() + blockId() + entryType() + currency() + description() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2249,12 +2978,12 @@ constructor( class Builder { - private var amount: Double? = null - private var blockId: String? = null - private var entryType: EntryType? = null - private var currency: String? = null - private var description: String? = null - private var metadata: Metadata? = null + private var amount: JsonField? = null + private var blockId: JsonField? = null + private var entryType: JsonField? = null + private var currency: JsonField = JsonMissing.of() + private var description: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2276,18 +3005,29 @@ constructor( * The number of credits to effect. Note that this is required for increment, decrement * or void operations. */ - fun amount(amount: Double) = apply { this.amount = amount } + fun amount(amount: Double) = amount(JsonField.of(amount)) + + /** + * The number of credits to effect. Note that this is required for increment, decrement + * or void operations. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** The ID of the block to reverse a decrement from. */ - fun blockId(blockId: String) = apply { this.blockId = blockId } + fun blockId(blockId: String) = blockId(JsonField.of(blockId)) - fun entryType(entryType: EntryType) = apply { this.entryType = entryType } + /** The ID of the block to reverse a decrement from. */ + fun blockId(blockId: JsonField) = apply { this.blockId = blockId } + + fun entryType(entryType: EntryType) = entryType(JsonField.of(entryType)) + + fun entryType(entryType: JsonField) = apply { this.entryType = entryType } /** * The currency or custom pricing unit to use for this ledger entry. If this is a * real-world currency, it must match the customer's invoicing currency. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * The currency or custom pricing unit to use for this ledger entry. If this is a @@ -2295,12 +3035,18 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * The currency or custom pricing unit to use for this ledger entry. If this is a + * real-world currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** * Optional metadata that can be specified when adding ledger results via the API. For * example, this can be used to note an increment refers to trial credits, or for noting * corrections as a result of an incident, etc. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** * Optional metadata that can be specified when adding ledger results via the API. For @@ -2309,12 +3055,21 @@ constructor( */ fun description(description: Optional) = description(description.orElse(null)) + /** + * Optional metadata that can be specified when adding ledger results via the API. For + * example, this can be used to note an increment refers to trial credits, or for noting + * corrections as a result of an incident, etc. + */ + fun description(description: JsonField) = apply { + this.description = description + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -2323,6 +3078,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2422,6 +3184,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt index 2ff60595..c33a94e1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerCreateEntryResponse.kt @@ -440,38 +440,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -507,19 +521,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -568,7 +582,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -639,19 +655,23 @@ private constructor( fun build(): IncrementLedgerEntry = IncrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -681,13 +701,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -713,9 +735,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -730,14 +752,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -767,9 +796,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -811,11 +842,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -840,8 +871,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -855,8 +886,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -886,8 +920,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1212,44 +1248,58 @@ private constructor( fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("event_id") @ExcludeMissing fun _eventId() = eventId + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId() = invoiceId + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing @@ -1288,19 +1338,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var eventId: JsonField = JsonMissing.of() private var invoiceId: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1355,7 +1405,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -1405,15 +1457,21 @@ private constructor( this.startingBalance = startingBalance } - fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) + + fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) + fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) + + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) fun priceId(priceId: JsonField) = apply { this.priceId = priceId } @@ -1438,19 +1496,23 @@ private constructor( fun build(): DecrementLedgerEntry = DecrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, eventId, invoiceId, priceId, @@ -1483,13 +1545,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -1515,9 +1579,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1532,14 +1596,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -1569,9 +1640,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1613,11 +1686,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -1642,8 +1715,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1657,8 +1730,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -1688,8 +1764,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2005,42 +2083,56 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2077,20 +2169,20 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2141,7 +2233,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2184,8 +2278,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) + fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = + newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) + + fun newBlockExpiryDate(newBlockExpiryDate: Optional) = + newBlockExpiryDate(newBlockExpiryDate.orElse(null)) fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { this.newBlockExpiryDate = newBlockExpiryDate @@ -2219,20 +2316,26 @@ private constructor( fun build(): ExpirationChangeLedgerEntry = ExpirationChangeLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2262,13 +2365,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -2294,9 +2399,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2311,14 +2416,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -2348,9 +2460,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2392,11 +2506,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -2421,8 +2535,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2436,8 +2550,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -2467,8 +2584,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2778,38 +2897,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2845,19 +2978,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2907,7 +3040,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2978,19 +3113,23 @@ private constructor( fun build(): CreditBlockExpiryLedgerEntry = CreditBlockExpiryLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3020,13 +3159,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3052,9 +3193,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3069,14 +3210,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3106,9 +3254,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3150,11 +3300,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3179,8 +3329,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3194,8 +3344,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -3225,8 +3378,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3547,42 +3702,60 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -3620,21 +3793,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3685,7 +3858,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -3739,7 +3914,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -3764,21 +3941,25 @@ private constructor( fun build(): VoidLedgerEntry = VoidLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3808,13 +3989,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3840,9 +4023,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3857,14 +4040,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3894,9 +4084,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3938,11 +4130,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3967,8 +4159,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3982,8 +4174,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4013,8 +4208,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4341,46 +4538,64 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -4419,22 +4634,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4486,7 +4701,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -4547,7 +4764,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -4572,22 +4791,28 @@ private constructor( fun build(): VoidInitiatedLedgerEntry = VoidInitiatedLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4617,13 +4842,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -4649,9 +4876,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4666,14 +4893,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -4703,9 +4937,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4747,11 +4983,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -4776,8 +5012,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4791,8 +5027,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4822,8 +5061,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5133,38 +5374,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -5200,19 +5455,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5261,7 +5516,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -5332,19 +5589,23 @@ private constructor( fun build(): AmendmentLedgerEntry = AmendmentLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5374,13 +5635,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -5406,9 +5669,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5423,14 +5686,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -5460,9 +5730,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5504,11 +5776,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -5533,8 +5805,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5548,8 +5820,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -5579,8 +5854,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt index 668f951b..2bc4387d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdParams.kt @@ -14,6 +14,84 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of + * actions that have taken place to modify a customer's credit balance. This + * [paginated endpoint](../reference/pagination) lists these entries, starting from the most recent + * ledger entry. + * + * More details on using Orb's real-time credit feature are + * [here](../guides/product-catalog/prepurchase.md). + * + * There are four major types of modifications to credit balance, detailed below. + * + * ## Increment + * + * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger + * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total + * eligible starting and ending balance for the customer at the time the entry was added to the + * ledger. + * + * ## Decrement + * + * Deductions can occur as a result of an API call to create a ledger entry (see + * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both + * ledger entries present the `decrement` entry type. + * + * As usage for a customer is reported into Orb, credits may be deducted according to the customer's + * plan configuration. An automated deduction of this type will result in a ledger entry, also with + * a starting and ending balance. In order to provide better tracing capabilities for automatic + * deductions, Orb always associates each automatic deduction with the `event_id` at the time of + * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are + * never deducted without an associated usage event. + * + * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit + * block_ first in order to ensure that all credits are utilized appropriately. As an example, if + * trial credits with an expiration date of 2 weeks from now are present for a customer, they will + * be used before any deductions take place from a non-expiring credit block. + * + * If there are multiple blocks with the same expiration date, Orb will deduct from the block with + * the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid credits with a + * $5.00 cost basis). + * + * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, + * Orb will deduct from the next block, ending at the credit block which consists of unexpiring + * credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block + * that is deducted from. By default, the customer's total credit balance in Orb can be negative as + * a result of a decrement. + * + * ## Expiration change + * + * The expiry of credits can be changed as a result of the API (See + * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the + * balance as well as the initial and target expiry dates. + * + * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` + * represents the balance transferred. The credit block linked to the ledger entry is the source + * credit block from which there was an expiration change + * + * ## Credits expiry + * + * When a set of credits expire on pre-set expiration date, the customer's balance automatically + * reflects this change and adds an entry to the ledger indicating this event. Note that credit + * expiry should always happen close to a date boundary in the customer's timezone. + * + * ## Void initiated + * + * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of + * credits that were remaining in the block at time of void. `void_reason` will be populated if the + * void is created with a reason. + * + * ## Void + * + * When a set of credits is voided, the customer's balance automatically reflects this change and + * adds an entry to the ledger indicating this event. + * + * ## Amendment + * + * When credits are added to a customer's balance as a result of a correction, this entry will be + * added to the ledger to indicate the adjustment of credits. + */ class CustomerCreditLedgerListByExternalIdParams constructor( private val externalCustomerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt index 48b9960e..7ec6413b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListByExternalIdResponse.kt @@ -451,38 +451,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -518,19 +532,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -579,7 +593,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -650,19 +666,23 @@ private constructor( fun build(): IncrementLedgerEntry = IncrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -692,13 +712,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -724,9 +746,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -741,14 +763,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -778,9 +807,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -822,11 +853,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -851,8 +882,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -866,8 +897,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -897,8 +931,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1223,44 +1259,58 @@ private constructor( fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("event_id") @ExcludeMissing fun _eventId() = eventId + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId() = invoiceId + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing @@ -1299,19 +1349,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var eventId: JsonField = JsonMissing.of() private var invoiceId: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1366,7 +1416,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -1416,15 +1468,21 @@ private constructor( this.startingBalance = startingBalance } - fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) + + fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) + fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) + + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) fun priceId(priceId: JsonField) = apply { this.priceId = priceId } @@ -1449,19 +1507,23 @@ private constructor( fun build(): DecrementLedgerEntry = DecrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, eventId, invoiceId, priceId, @@ -1494,13 +1556,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -1526,9 +1590,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1543,14 +1607,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -1580,9 +1651,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1624,11 +1697,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -1653,8 +1726,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1668,8 +1741,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -1699,8 +1775,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2016,42 +2094,56 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2088,20 +2180,20 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2152,7 +2244,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2195,8 +2289,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) + fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = + newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) + + fun newBlockExpiryDate(newBlockExpiryDate: Optional) = + newBlockExpiryDate(newBlockExpiryDate.orElse(null)) fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { this.newBlockExpiryDate = newBlockExpiryDate @@ -2230,20 +2327,26 @@ private constructor( fun build(): ExpirationChangeLedgerEntry = ExpirationChangeLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2273,13 +2376,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -2305,9 +2410,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2322,14 +2427,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -2359,9 +2471,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2403,11 +2517,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -2432,8 +2546,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2447,8 +2561,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -2478,8 +2595,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2789,38 +2908,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2856,19 +2989,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2918,7 +3051,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2989,19 +3124,23 @@ private constructor( fun build(): CreditBlockExpiryLedgerEntry = CreditBlockExpiryLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3031,13 +3170,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3063,9 +3204,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3080,14 +3221,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3117,9 +3265,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3161,11 +3311,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3190,8 +3340,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3205,8 +3355,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -3236,8 +3389,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3558,42 +3713,60 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -3631,21 +3804,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3696,7 +3869,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -3750,7 +3925,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -3775,21 +3952,25 @@ private constructor( fun build(): VoidLedgerEntry = VoidLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3819,13 +4000,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3851,9 +4034,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3868,14 +4051,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3905,9 +4095,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3949,11 +4141,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3978,8 +4170,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3993,8 +4185,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4024,8 +4219,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4352,46 +4549,64 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -4430,22 +4645,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4497,7 +4712,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -4558,7 +4775,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -4583,22 +4802,28 @@ private constructor( fun build(): VoidInitiatedLedgerEntry = VoidInitiatedLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4628,13 +4853,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -4660,9 +4887,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4677,14 +4904,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -4714,9 +4948,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4758,11 +4994,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -4787,8 +5023,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4802,8 +5038,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4833,8 +5072,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5144,38 +5385,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -5211,19 +5466,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5272,7 +5527,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -5343,19 +5600,23 @@ private constructor( fun build(): AmendmentLedgerEntry = AmendmentLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5385,13 +5646,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -5417,9 +5680,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5434,14 +5697,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -5471,9 +5741,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5515,11 +5787,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -5544,8 +5816,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5559,8 +5831,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -5590,8 +5865,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt index 5f8c9371..90f10db2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListParams.kt @@ -14,6 +14,84 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * The credits ledger provides _auditing_ functionality over Orb's credits system with a list of + * actions that have taken place to modify a customer's credit balance. This + * [paginated endpoint](../reference/pagination) lists these entries, starting from the most recent + * ledger entry. + * + * More details on using Orb's real-time credit feature are + * [here](../guides/product-catalog/prepurchase.md). + * + * There are four major types of modifications to credit balance, detailed below. + * + * ## Increment + * + * Credits (which optionally expire on a future date) can be added via the API ([Add Ledger + * Entry](create-ledger-entry)). The ledger entry for such an action will always contain the total + * eligible starting and ending balance for the customer at the time the entry was added to the + * ledger. + * + * ## Decrement + * + * Deductions can occur as a result of an API call to create a ledger entry (see + * [Add Ledger Entry](create-ledger-entry)), or automatically as a result of incurring usage. Both + * ledger entries present the `decrement` entry type. + * + * As usage for a customer is reported into Orb, credits may be deducted according to the customer's + * plan configuration. An automated deduction of this type will result in a ledger entry, also with + * a starting and ending balance. In order to provide better tracing capabilities for automatic + * deductions, Orb always associates each automatic deduction with the `event_id` at the time of + * ingestion, used to pinpoint _why_ credit deduction took place and to ensure that credits are + * never deducted without an associated usage event. + * + * By default, Orb uses an algorithm that automatically deducts from the _soonest expiring credit + * block_ first in order to ensure that all credits are utilized appropriately. As an example, if + * trial credits with an expiration date of 2 weeks from now are present for a customer, they will + * be used before any deductions take place from a non-expiring credit block. + * + * If there are multiple blocks with the same expiration date, Orb will deduct from the block with + * the _lower cost basis_ first (e.g. trial credits with a $0 cost basis before paid credits with a + * $5.00 cost basis). + * + * It's also possible for a single usage event's deduction to _span_ credit blocks. In this case, + * Orb will deduct from the next block, ending at the credit block which consists of unexpiring + * credits. Each of these deductions will lead to a _separate_ ledger entry, one per credit block + * that is deducted from. By default, the customer's total credit balance in Orb can be negative as + * a result of a decrement. + * + * ## Expiration change + * + * The expiry of credits can be changed as a result of the API (See + * [Add Ledger Entry](create-ledger-entry)). This will create a ledger entry that specifies the + * balance as well as the initial and target expiry dates. + * + * Note that for this entry type, `starting_balance` will equal `ending_balance`, and the `amount` + * represents the balance transferred. The credit block linked to the ledger entry is the source + * credit block from which there was an expiration change + * + * ## Credits expiry + * + * When a set of credits expire on pre-set expiration date, the customer's balance automatically + * reflects this change and adds an entry to the ledger indicating this event. Note that credit + * expiry should always happen close to a date boundary in the customer's timezone. + * + * ## Void initiated + * + * Credit blocks can be voided via the API. The `amount` on this entry corresponds to the number of + * credits that were remaining in the block at time of void. `void_reason` will be populated if the + * void is created with a reason. + * + * ## Void + * + * When a set of credits is voided, the customer's balance automatically reflects this change and + * adds an entry to the ledger indicating this event. + * + * ## Amendment + * + * When credits are added to a customer's balance as a result of a correction, this entry will be + * added to the ledger to indicate the adjustment of credits. + */ class CustomerCreditLedgerListParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt index 9465c031..a38e8399 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditLedgerListResponse.kt @@ -431,38 +431,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -498,19 +512,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -559,7 +573,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -630,19 +646,23 @@ private constructor( fun build(): IncrementLedgerEntry = IncrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -672,13 +692,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -704,9 +726,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -721,14 +743,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -758,9 +787,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -802,11 +833,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -831,8 +862,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -846,8 +877,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -877,8 +911,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1203,44 +1239,58 @@ private constructor( fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("event_id") @ExcludeMissing fun _eventId() = eventId + @JsonProperty("event_id") @ExcludeMissing fun _eventId(): JsonField = eventId - @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId() = invoiceId + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing @@ -1279,19 +1329,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var eventId: JsonField = JsonMissing.of() private var invoiceId: JsonField = JsonMissing.of() private var priceId: JsonField = JsonMissing.of() @@ -1346,7 +1396,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -1396,15 +1448,21 @@ private constructor( this.startingBalance = startingBalance } - fun eventId(eventId: String) = eventId(JsonField.of(eventId)) + fun eventId(eventId: String?) = eventId(JsonField.ofNullable(eventId)) + + fun eventId(eventId: Optional) = eventId(eventId.orElse(null)) fun eventId(eventId: JsonField) = apply { this.eventId = eventId } - fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) + fun invoiceId(invoiceId: String?) = invoiceId(JsonField.ofNullable(invoiceId)) + + fun invoiceId(invoiceId: Optional) = invoiceId(invoiceId.orElse(null)) fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } - fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) + + fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) fun priceId(priceId: JsonField) = apply { this.priceId = priceId } @@ -1429,19 +1487,23 @@ private constructor( fun build(): DecrementLedgerEntry = DecrementLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, eventId, invoiceId, priceId, @@ -1474,13 +1536,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -1506,9 +1570,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1523,14 +1587,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -1560,9 +1631,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1604,11 +1677,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -1633,8 +1706,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1648,8 +1721,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -1679,8 +1755,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1996,42 +2074,56 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2068,20 +2160,20 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2132,7 +2224,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2175,8 +2269,11 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime) = - newBlockExpiryDate(JsonField.of(newBlockExpiryDate)) + fun newBlockExpiryDate(newBlockExpiryDate: OffsetDateTime?) = + newBlockExpiryDate(JsonField.ofNullable(newBlockExpiryDate)) + + fun newBlockExpiryDate(newBlockExpiryDate: Optional) = + newBlockExpiryDate(newBlockExpiryDate.orElse(null)) fun newBlockExpiryDate(newBlockExpiryDate: JsonField) = apply { this.newBlockExpiryDate = newBlockExpiryDate @@ -2210,20 +2307,26 @@ private constructor( fun build(): ExpirationChangeLedgerEntry = ExpirationChangeLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2253,13 +2356,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -2285,9 +2390,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2302,14 +2407,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -2339,9 +2451,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2383,11 +2497,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -2412,8 +2526,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2427,8 +2541,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -2458,8 +2575,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2769,38 +2888,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -2836,19 +2969,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2898,7 +3031,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -2969,19 +3104,23 @@ private constructor( fun build(): CreditBlockExpiryLedgerEntry = CreditBlockExpiryLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3011,13 +3150,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3043,9 +3184,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3060,14 +3201,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3097,9 +3245,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3141,11 +3291,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3170,8 +3320,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3185,8 +3335,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -3216,8 +3369,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3538,42 +3693,60 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -3611,21 +3784,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3676,7 +3849,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -3730,7 +3905,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -3755,21 +3932,25 @@ private constructor( fun build(): VoidLedgerEntry = VoidLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3799,13 +3980,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -3831,9 +4014,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3848,14 +4031,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -3885,9 +4075,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3929,11 +4121,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -3958,8 +4150,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3973,8 +4165,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4004,8 +4199,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4332,46 +4529,64 @@ private constructor( fun voidReason(): Optional = Optional.ofNullable(voidReason.getNullable("void_reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonProperty("new_block_expiry_date") @ExcludeMissing - fun _newBlockExpiryDate() = newBlockExpiryDate + fun _newBlockExpiryDate(): JsonField = newBlockExpiryDate - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("void_amount") @ExcludeMissing fun _voidAmount() = voidAmount + @JsonProperty("void_amount") + @ExcludeMissing + fun _voidAmount(): JsonField = voidAmount - @JsonProperty("void_reason") @ExcludeMissing fun _voidReason() = voidReason + @JsonProperty("void_reason") + @ExcludeMissing + fun _voidReason(): JsonField = voidReason @JsonAnyGetter @ExcludeMissing @@ -4410,22 +4625,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var newBlockExpiryDate: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var voidAmount: JsonField = JsonMissing.of() - private var voidReason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var newBlockExpiryDate: JsonField? = null + private var startingBalance: JsonField? = null + private var voidAmount: JsonField? = null + private var voidReason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4477,7 +4692,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -4538,7 +4755,9 @@ private constructor( fun voidAmount(voidAmount: JsonField) = apply { this.voidAmount = voidAmount } - fun voidReason(voidReason: String) = voidReason(JsonField.of(voidReason)) + fun voidReason(voidReason: String?) = voidReason(JsonField.ofNullable(voidReason)) + + fun voidReason(voidReason: Optional) = voidReason(voidReason.orElse(null)) fun voidReason(voidReason: JsonField) = apply { this.voidReason = voidReason } @@ -4563,22 +4782,28 @@ private constructor( fun build(): VoidInitiatedLedgerEntry = VoidInitiatedLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - newBlockExpiryDate, - startingBalance, - voidAmount, - voidReason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(newBlockExpiryDate) { + "`newBlockExpiryDate` is required but was not set" + }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(voidAmount) { "`voidAmount` is required but was not set" }, + checkNotNull(voidReason) { "`voidReason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4608,13 +4833,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -4640,9 +4867,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4657,14 +4884,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -4694,9 +4928,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4738,11 +4974,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -4767,8 +5003,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4782,8 +5018,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -4813,8 +5052,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5124,38 +5365,52 @@ private constructor( fun startingBalance(): Double = startingBalance.getRequired("starting_balance") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_block") @ExcludeMissing fun _creditBlock() = creditBlock + @JsonProperty("credit_block") + @ExcludeMissing + fun _creditBlock(): JsonField = creditBlock - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("entry_status") @ExcludeMissing fun _entryStatus() = entryStatus + @JsonProperty("entry_status") + @ExcludeMissing + fun _entryStatus(): JsonField = entryStatus - @JsonProperty("entry_type") @ExcludeMissing fun _entryType() = entryType + @JsonProperty("entry_type") + @ExcludeMissing + fun _entryType(): JsonField = entryType @JsonProperty("ledger_sequence_number") @ExcludeMissing - fun _ledgerSequenceNumber() = ledgerSequenceNumber + fun _ledgerSequenceNumber(): JsonField = ledgerSequenceNumber /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance @JsonAnyGetter @ExcludeMissing @@ -5191,19 +5446,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditBlock: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var entryStatus: JsonField = JsonMissing.of() - private var entryType: JsonField = JsonMissing.of() - private var ledgerSequenceNumber: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditBlock: JsonField? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var entryStatus: JsonField? = null + private var entryType: JsonField? = null + private var ledgerSequenceNumber: JsonField? = null + private var metadata: JsonField? = null + private var startingBalance: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5252,7 +5507,9 @@ private constructor( fun customer(customer: JsonField) = apply { this.customer = customer } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description @@ -5323,19 +5580,23 @@ private constructor( fun build(): AmendmentLedgerEntry = AmendmentLedgerEntry( - id, - amount, - createdAt, - creditBlock, - currency, - customer, - description, - endingBalance, - entryStatus, - entryType, - ledgerSequenceNumber, - metadata, - startingBalance, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditBlock) { "`creditBlock` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(entryStatus) { "`entryStatus` is required but was not set" }, + checkNotNull(entryType) { "`entryType` is required but was not set" }, + checkNotNull(ledgerSequenceNumber) { + "`ledgerSequenceNumber` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5365,13 +5626,15 @@ private constructor( fun perUnitCostBasis(): Optional = Optional.ofNullable(perUnitCostBasis.getNullable("per_unit_cost_basis")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("per_unit_cost_basis") @ExcludeMissing - fun _perUnitCostBasis() = perUnitCostBasis + fun _perUnitCostBasis(): JsonField = perUnitCostBasis @JsonAnyGetter @ExcludeMissing @@ -5397,9 +5660,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var expiryDate: JsonField? = null + private var perUnitCostBasis: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5414,14 +5677,21 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = + expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = + expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -5451,9 +5721,11 @@ private constructor( fun build(): CreditBlock = CreditBlock( - id, - expiryDate, - perUnitCostBasis, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(perUnitCostBasis) { + "`perUnitCostBasis` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5495,11 +5767,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -5524,8 +5796,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5539,8 +5811,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -5570,8 +5845,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt index 0d5b699b..dcf9edbb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdParams.kt @@ -8,6 +8,15 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * Returns a paginated list of unexpired, non-zero credit blocks for a customer. + * + * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted + * blocks) will be included in the response. + * + * Note that `currency` defaults to credits if not specified. To use a real world currency, set + * `currency` to an ISO 4217 string. + */ class CustomerCreditListByExternalIdParams constructor( private val externalCustomerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt index e48839cc..0519355a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListByExternalIdResponse.kt @@ -63,21 +63,27 @@ private constructor( fun status(): Status = status.getRequired("status") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("balance") @ExcludeMissing fun _balance() = balance + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("maximum_initial_balance") @ExcludeMissing - fun _maximumInitialBalance() = maximumInitialBalance + fun _maximumInitialBalance(): JsonField = maximumInitialBalance - @JsonProperty("per_unit_cost_basis") @ExcludeMissing fun _perUnitCostBasis() = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -107,13 +113,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var maximumInitialBalance: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var balance: JsonField? = null + private var effectiveDate: JsonField? = null + private var expiryDate: JsonField? = null + private var maximumInitialBalance: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -139,28 +145,43 @@ private constructor( fun balance(balance: JsonField) = apply { this.balance = balance } - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.orElse(null)) fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } + fun maximumInitialBalance(maximumInitialBalance: Double?) = + maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) + fun maximumInitialBalance(maximumInitialBalance: Double) = - maximumInitialBalance(JsonField.of(maximumInitialBalance)) + maximumInitialBalance(maximumInitialBalance as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maximumInitialBalance(maximumInitialBalance: Optional) = + maximumInitialBalance(maximumInitialBalance.orElse(null) as Double?) fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { this.maximumInitialBalance = maximumInitialBalance } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -191,13 +212,15 @@ private constructor( fun build(): CustomerCreditListByExternalIdResponse = CustomerCreditListByExternalIdResponse( - id, - balance, - effectiveDate, - expiryDate, - maximumInitialBalance, - perUnitCostBasis, - status, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(balance) { "`balance` is required but was not set" }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(maximumInitialBalance) { + "`maximumInitialBalance` is required but was not set" + }, + checkNotNull(perUnitCostBasis) { "`perUnitCostBasis` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt index 7834e45b..a0d5a550 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListParams.kt @@ -8,6 +8,15 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * Returns a paginated list of unexpired, non-zero credit blocks for a customer. + * + * If `include_all_blocks` is set to `true`, all credit blocks (including expired and depleted + * blocks) will be included in the response. + * + * Note that `currency` defaults to credits if not specified. To use a real world currency, set + * `currency` to an ISO 4217 string. + */ class CustomerCreditListParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt index c568724b..7b4ab765 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditListResponse.kt @@ -63,21 +63,27 @@ private constructor( fun status(): Status = status.getRequired("status") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("balance") @ExcludeMissing fun _balance() = balance + @JsonProperty("balance") @ExcludeMissing fun _balance(): JsonField = balance - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("expiry_date") @ExcludeMissing fun _expiryDate() = expiryDate + @JsonProperty("expiry_date") + @ExcludeMissing + fun _expiryDate(): JsonField = expiryDate @JsonProperty("maximum_initial_balance") @ExcludeMissing - fun _maximumInitialBalance() = maximumInitialBalance + fun _maximumInitialBalance(): JsonField = maximumInitialBalance - @JsonProperty("per_unit_cost_basis") @ExcludeMissing fun _perUnitCostBasis() = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing @@ -107,13 +113,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var balance: JsonField = JsonMissing.of() - private var effectiveDate: JsonField = JsonMissing.of() - private var expiryDate: JsonField = JsonMissing.of() - private var maximumInitialBalance: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var balance: JsonField? = null + private var effectiveDate: JsonField? = null + private var expiryDate: JsonField? = null + private var maximumInitialBalance: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var status: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -136,28 +142,43 @@ private constructor( fun balance(balance: JsonField) = apply { this.balance = balance } - fun effectiveDate(effectiveDate: OffsetDateTime) = - effectiveDate(JsonField.of(effectiveDate)) + fun effectiveDate(effectiveDate: OffsetDateTime?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) + + fun effectiveDate(effectiveDate: Optional) = + effectiveDate(effectiveDate.orElse(null)) fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } - fun expiryDate(expiryDate: OffsetDateTime) = expiryDate(JsonField.of(expiryDate)) + fun expiryDate(expiryDate: OffsetDateTime?) = expiryDate(JsonField.ofNullable(expiryDate)) + + fun expiryDate(expiryDate: Optional) = expiryDate(expiryDate.orElse(null)) fun expiryDate(expiryDate: JsonField) = apply { this.expiryDate = expiryDate } + fun maximumInitialBalance(maximumInitialBalance: Double?) = + maximumInitialBalance(JsonField.ofNullable(maximumInitialBalance)) + fun maximumInitialBalance(maximumInitialBalance: Double) = - maximumInitialBalance(JsonField.of(maximumInitialBalance)) + maximumInitialBalance(maximumInitialBalance as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maximumInitialBalance(maximumInitialBalance: Optional) = + maximumInitialBalance(maximumInitialBalance.orElse(null) as Double?) fun maximumInitialBalance(maximumInitialBalance: JsonField) = apply { this.maximumInitialBalance = maximumInitialBalance } - fun perUnitCostBasis(perUnitCostBasis: String) = - perUnitCostBasis(JsonField.of(perUnitCostBasis)) + fun perUnitCostBasis(perUnitCostBasis: String?) = + perUnitCostBasis(JsonField.ofNullable(perUnitCostBasis)) + + fun perUnitCostBasis(perUnitCostBasis: Optional) = + perUnitCostBasis(perUnitCostBasis.orElse(null)) fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis @@ -188,13 +209,15 @@ private constructor( fun build(): CustomerCreditListResponse = CustomerCreditListResponse( - id, - balance, - effectiveDate, - expiryDate, - maximumInitialBalance, - perUnitCostBasis, - status, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(balance) { "`balance` is required but was not set" }, + checkNotNull(effectiveDate) { "`effectiveDate` is required but was not set" }, + checkNotNull(expiryDate) { "`expiryDate` is required but was not set" }, + checkNotNull(maximumInitialBalance) { + "`maximumInitialBalance` is required but was not set" + }, + checkNotNull(perUnitCostBasis) { "`perUnitCostBasis` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt index 03ff4dff..c6eeec34 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,14 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to create a new top-up for a specified customer's balance. While this + * top-up is active, the customer's balance will added in increments of the specified amount + * whenever the balance reaches the specified threshold. + * + * If a top-up already exists for this customer in the same currency, the existing top-up will be + * replaced. + */ class CustomerCreditTopUpCreateByExternalIdParams constructor( private val externalCustomerId: String, @@ -59,12 +68,42 @@ constructor( /** The unit of expires_after. */ fun expiresAfterUnit(): Optional = body.expiresAfterUnit() - fun _additionalHeaders(): Headers = additionalHeaders + /** The amount to increment when the threshold is reached. */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, + * it must match the customer's invoicing currency. + */ + fun _currency(): JsonField = body._currency() + + /** Settings for invoices generated by triggered top-ups. */ + fun _invoiceSettings(): JsonField = body._invoiceSettings() + + /** How much, in the customer's currency, to charge for each unit. */ + fun _perUnitCostBasis(): JsonField = body._perUnitCostBasis() + + /** + * The threshold at which to trigger the top-up. If the balance is at or below this threshold, + * the top-up will be triggered. + */ + fun _threshold(): JsonField = body._threshold() + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun _expiresAfter(): JsonField = body._expiresAfter() + + /** The unit of expires_after. */ + fun _expiresAfterUnit(): JsonField = body._expiresAfterUnit() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CustomerCreditTopUpCreateByExternalIdBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -82,53 +121,120 @@ constructor( class CustomerCreditTopUpCreateByExternalIdBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: String, - @JsonProperty("currency") private val currency: String, - @JsonProperty("invoice_settings") private val invoiceSettings: InvoiceSettings, - @JsonProperty("per_unit_cost_basis") private val perUnitCostBasis: String, - @JsonProperty("threshold") private val threshold: String, - @JsonProperty("expires_after") private val expiresAfter: Long?, - @JsonProperty("expires_after_unit") private val expiresAfterUnit: ExpiresAfterUnit?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("invoice_settings") + @ExcludeMissing + private val invoiceSettings: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonProperty("threshold") + @ExcludeMissing + private val threshold: JsonField = JsonMissing.of(), + @JsonProperty("expires_after") + @ExcludeMissing + private val expiresAfter: JsonField = JsonMissing.of(), + @JsonProperty("expires_after_unit") + @ExcludeMissing + private val expiresAfterUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") fun amount(): String = amount + fun amount(): String = amount.getRequired("amount") + + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): String = currency.getRequired("currency") + + /** Settings for invoices generated by triggered top-ups. */ + fun invoiceSettings(): InvoiceSettings = invoiceSettings.getRequired("invoice_settings") + + /** How much, in the customer's currency, to charge for each unit. */ + fun perUnitCostBasis(): String = perUnitCostBasis.getRequired("per_unit_cost_basis") + + /** + * The threshold at which to trigger the top-up. If the balance is at or below this + * threshold, the top-up will be triggered. + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(): Optional = + Optional.ofNullable(expiresAfter.getNullable("expires_after")) + + /** The unit of expires_after. */ + fun expiresAfterUnit(): Optional = + Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) + + /** The amount to increment when the threshold is reached. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The currency or custom pricing unit to use for this top-up. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") fun invoiceSettings(): InvoiceSettings = invoiceSettings + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") fun perUnitCostBasis(): String = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis /** * The threshold at which to trigger the top-up. If the balance is at or below this * threshold, the top-up will be triggered. */ - @JsonProperty("threshold") fun threshold(): String = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ @JsonProperty("expires_after") - fun expiresAfter(): Optional = Optional.ofNullable(expiresAfter) + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter /** The unit of expires_after. */ @JsonProperty("expires_after_unit") - fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit) + @ExcludeMissing + fun _expiresAfterUnit(): JsonField = expiresAfterUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomerCreditTopUpCreateByExternalIdBody = apply { + if (!validated) { + amount() + currency() + invoiceSettings().validate() + perUnitCostBasis() + threshold() + expiresAfter() + expiresAfterUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -138,13 +244,13 @@ constructor( class Builder { - private var amount: String? = null - private var currency: String? = null - private var invoiceSettings: InvoiceSettings? = null - private var perUnitCostBasis: String? = null - private var threshold: String? = null - private var expiresAfter: Long? = null - private var expiresAfterUnit: ExpiresAfterUnit? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var invoiceSettings: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var threshold: JsonField? = null + private var expiresAfter: JsonField = JsonMissing.of() + private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -163,21 +269,38 @@ constructor( } /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = apply { this.amount = amount } + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The amount to increment when the threshold is reached. */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** * The currency or custom pricing unit to use for this top-up. If this is a real-world * currency, it must match the customer's invoicing currency. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = apply { + fun invoiceSettings(invoiceSettings: InvoiceSettings) = + invoiceSettings(JsonField.of(invoiceSettings)) + + /** Settings for invoices generated by triggered top-ups. */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { this.invoiceSettings = invoiceSettings } /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = apply { + fun perUnitCostBasis(perUnitCostBasis: String) = + perUnitCostBasis(JsonField.of(perUnitCostBasis)) + + /** How much, in the customer's currency, to charge for each unit. */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis } @@ -185,13 +308,19 @@ constructor( * The threshold at which to trigger the top-up. If the balance is at or below this * threshold, the top-up will be triggered. */ - fun threshold(threshold: String) = apply { this.threshold = threshold } + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * The threshold at which to trigger the top-up. If the balance is at or below this + * threshold, the top-up will be triggered. + */ + fun threshold(threshold: JsonField) = apply { this.threshold = threshold } /** * The number of days or months after which the top-up expires. If unspecified, it does * not expire. */ - fun expiresAfter(expiresAfter: Long?) = apply { this.expiresAfter = expiresAfter } + fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) /** * The number of days or months after which the top-up expires. If unspecified, it does @@ -207,15 +336,27 @@ constructor( fun expiresAfter(expiresAfter: Optional) = expiresAfter(expiresAfter.orElse(null) as Long?) - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = apply { - this.expiresAfterUnit = expiresAfterUnit + /** + * The number of days or months after which the top-up expires. If unspecified, it does + * not expire. + */ + fun expiresAfter(expiresAfter: JsonField) = apply { + this.expiresAfter = expiresAfter } + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = + expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) + /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: Optional) = expiresAfterUnit(expiresAfterUnit.orElse(null)) + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { + this.expiresAfterUnit = expiresAfterUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -305,28 +446,53 @@ constructor( /** The amount to increment when the threshold is reached. */ fun amount(amount: String) = apply { body.amount(amount) } + /** The amount to increment when the threshold is reached. */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** * The currency or custom pricing unit to use for this top-up. If this is a real-world * currency, it must match the customer's invoicing currency. */ fun currency(currency: String) = apply { body.currency(currency) } + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** Settings for invoices generated by triggered top-ups. */ fun invoiceSettings(invoiceSettings: InvoiceSettings) = apply { body.invoiceSettings(invoiceSettings) } + /** Settings for invoices generated by triggered top-ups. */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { + body.invoiceSettings(invoiceSettings) + } + /** How much, in the customer's currency, to charge for each unit. */ fun perUnitCostBasis(perUnitCostBasis: String) = apply { body.perUnitCostBasis(perUnitCostBasis) } + /** How much, in the customer's currency, to charge for each unit. */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + body.perUnitCostBasis(perUnitCostBasis) + } + /** * The threshold at which to trigger the top-up. If the balance is at or below this * threshold, the top-up will be triggered. */ fun threshold(threshold: String) = apply { body.threshold(threshold) } + /** + * The threshold at which to trigger the top-up. If the balance is at or below this + * threshold, the top-up will be triggered. + */ + fun threshold(threshold: JsonField) = apply { body.threshold(threshold) } + /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. @@ -347,6 +513,12 @@ constructor( fun expiresAfter(expiresAfter: Optional) = expiresAfter(expiresAfter.orElse(null) as Long?) + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(expiresAfter: JsonField) = apply { body.expiresAfter(expiresAfter) } + /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = apply { body.expiresAfterUnit(expiresAfterUnit) @@ -356,6 +528,30 @@ constructor( fun expiresAfterUnit(expiresAfterUnit: Optional) = expiresAfterUnit(expiresAfterUnit.orElse(null)) + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { + body.expiresAfterUnit(expiresAfterUnit) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -454,25 +650,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CustomerCreditTopUpCreateByExternalIdParams = CustomerCreditTopUpCreateByExternalIdParams( checkNotNull(externalCustomerId) { @@ -489,10 +666,18 @@ constructor( class InvoiceSettings @JsonCreator private constructor( - @JsonProperty("auto_collection") private val autoCollection: Boolean, - @JsonProperty("net_terms") private val netTerms: Long, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("require_successful_payment") private val requireSuccessfulPayment: Boolean?, + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("require_successful_payment") + @ExcludeMissing + private val requireSuccessfulPayment: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -501,29 +686,65 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") fun autoCollection(): Boolean = autoCollection + fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") fun netTerms(): Long = netTerms + fun netTerms(): Long = netTerms.getRequired("net_terms") /** An optional memo to display on the invoice. */ - @JsonProperty("memo") fun memo(): Optional = Optional.ofNullable(memo) + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) /** * If true, new credit blocks created by this top-up will require that the corresponding * invoice is paid before they can be drawn down from. */ - @JsonProperty("require_successful_payment") fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment) + Optional.ofNullable(requireSuccessfulPayment.getNullable("require_successful_payment")) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** An optional memo to display on the invoice. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * If true, new credit blocks created by this top-up will require that the corresponding + * invoice is paid before they can be drawn down from. + */ + @JsonProperty("require_successful_payment") + @ExcludeMissing + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceSettings = apply { + if (!validated) { + autoCollection() + netTerms() + memo() + requireSuccessfulPayment() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -533,10 +754,10 @@ constructor( class Builder { - private var autoCollection: Boolean? = null - private var netTerms: Long? = null - private var memo: String? = null - private var requireSuccessfulPayment: Boolean? = null + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null + private var memo: JsonField = JsonMissing.of() + private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -552,7 +773,14 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - fun autoCollection(autoCollection: Boolean) = apply { + fun autoCollection(autoCollection: Boolean) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + fun autoCollection(autoCollection: JsonField) = apply { this.autoCollection = autoCollection } @@ -560,36 +788,37 @@ constructor( * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. */ - fun netTerms(netTerms: Long) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** An optional memo to display on the invoice. */ fun memo(memo: Optional) = memo(memo.orElse(null)) - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean?) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } + /** An optional memo to display on the invoice. */ + fun memo(memo: JsonField) = apply { this.memo = memo } /** * If true, new credit blocks created by this top-up will require that the corresponding * invoice is paid before they can be drawn down from. */ fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(requireSuccessfulPayment as Boolean?) + requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) /** * If true, new credit blocks created by this top-up will require that the corresponding * invoice is paid before they can be drawn down from. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun requireSuccessfulPayment(requireSuccessfulPayment: Optional) = - requireSuccessfulPayment(requireSuccessfulPayment.orElse(null) as Boolean?) + fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { + this.requireSuccessfulPayment = requireSuccessfulPayment + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt index c18400a8..fcd28688 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateByExternalIdResponse.kt @@ -81,37 +81,45 @@ private constructor( fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, * it must match the customer's invoicing currency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") @ExcludeMissing fun _invoiceSettings() = invoiceSettings + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") @ExcludeMissing fun _perUnitCostBasis() = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis /** * The threshold at which to trigger the top-up. If the balance is at or below this threshold, * the top-up will be triggered. */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold() = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - @JsonProperty("expires_after") @ExcludeMissing fun _expiresAfter() = expiresAfter + @JsonProperty("expires_after") + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") @ExcludeMissing fun _expiresAfterUnit() = expiresAfterUnit + @JsonProperty("expires_after_unit") + @ExcludeMissing + fun _expiresAfterUnit(): JsonField = expiresAfterUnit @JsonAnyGetter @ExcludeMissing @@ -142,12 +150,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var invoiceSettings: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var threshold: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var invoiceSettings: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var threshold: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -225,7 +233,21 @@ private constructor( * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(JsonField.of(expiresAfter)) + fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun expiresAfter(expiresAfter: Optional) = + expiresAfter(expiresAfter.orElse(null) as Long?) /** * The number of days or months after which the top-up expires. If unspecified, it does not @@ -234,8 +256,12 @@ private constructor( fun expiresAfter(expiresAfter: JsonField) = apply { this.expiresAfter = expiresAfter } /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit) = - expiresAfterUnit(JsonField.of(expiresAfterUnit)) + fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = + expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) + + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: Optional) = + expiresAfterUnit(expiresAfterUnit.orElse(null)) /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { @@ -263,12 +289,12 @@ private constructor( fun build(): CustomerCreditTopUpCreateByExternalIdResponse = CustomerCreditTopUpCreateByExternalIdResponse( - id, - amount, - currency, - invoiceSettings, - perUnitCostBasis, - threshold, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(invoiceSettings) { "`invoiceSettings` is required but was not set" }, + checkNotNull(perUnitCostBasis) { "`perUnitCostBasis` is required but was not set" }, + checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, additionalProperties.toImmutable(), @@ -322,16 +348,18 @@ private constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * If true, new credit blocks created by this top-up will require that the corresponding @@ -339,7 +367,7 @@ private constructor( */ @JsonProperty("require_successful_payment") @ExcludeMissing - fun _requireSuccessfulPayment() = requireSuccessfulPayment + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing @@ -366,8 +394,8 @@ private constructor( class Builder { - private var autoCollection: JsonField = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -409,7 +437,10 @@ private constructor( fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo to display on the invoice. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo to display on the invoice. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -450,8 +481,8 @@ private constructor( fun build(): InvoiceSettings = InvoiceSettings( - autoCollection, - netTerms, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, additionalProperties.toImmutable(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt index 52cea74b..af24104e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,14 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to create a new top-up for a specified customer's balance. While this + * top-up is active, the customer's balance will added in increments of the specified amount + * whenever the balance reaches the specified threshold. + * + * If a top-up already exists for this customer in the same currency, the existing top-up will be + * replaced. + */ class CustomerCreditTopUpCreateParams constructor( private val customerId: String, @@ -59,12 +68,42 @@ constructor( /** The unit of expires_after. */ fun expiresAfterUnit(): Optional = body.expiresAfterUnit() - fun _additionalHeaders(): Headers = additionalHeaders + /** The amount to increment when the threshold is reached. */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, + * it must match the customer's invoicing currency. + */ + fun _currency(): JsonField = body._currency() + + /** Settings for invoices generated by triggered top-ups. */ + fun _invoiceSettings(): JsonField = body._invoiceSettings() + + /** How much, in the customer's currency, to charge for each unit. */ + fun _perUnitCostBasis(): JsonField = body._perUnitCostBasis() + + /** + * The threshold at which to trigger the top-up. If the balance is at or below this threshold, + * the top-up will be triggered. + */ + fun _threshold(): JsonField = body._threshold() + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun _expiresAfter(): JsonField = body._expiresAfter() + + /** The unit of expires_after. */ + fun _expiresAfterUnit(): JsonField = body._expiresAfterUnit() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CustomerCreditTopUpCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -82,53 +121,120 @@ constructor( class CustomerCreditTopUpCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: String, - @JsonProperty("currency") private val currency: String, - @JsonProperty("invoice_settings") private val invoiceSettings: InvoiceSettings, - @JsonProperty("per_unit_cost_basis") private val perUnitCostBasis: String, - @JsonProperty("threshold") private val threshold: String, - @JsonProperty("expires_after") private val expiresAfter: Long?, - @JsonProperty("expires_after_unit") private val expiresAfterUnit: ExpiresAfterUnit?, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("invoice_settings") + @ExcludeMissing + private val invoiceSettings: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + private val perUnitCostBasis: JsonField = JsonMissing.of(), + @JsonProperty("threshold") + @ExcludeMissing + private val threshold: JsonField = JsonMissing.of(), + @JsonProperty("expires_after") + @ExcludeMissing + private val expiresAfter: JsonField = JsonMissing.of(), + @JsonProperty("expires_after_unit") + @ExcludeMissing + private val expiresAfterUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") fun amount(): String = amount + fun amount(): String = amount.getRequired("amount") + + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(): String = currency.getRequired("currency") + + /** Settings for invoices generated by triggered top-ups. */ + fun invoiceSettings(): InvoiceSettings = invoiceSettings.getRequired("invoice_settings") + + /** How much, in the customer's currency, to charge for each unit. */ + fun perUnitCostBasis(): String = perUnitCostBasis.getRequired("per_unit_cost_basis") + + /** + * The threshold at which to trigger the top-up. If the balance is at or below this + * threshold, the top-up will be triggered. + */ + fun threshold(): String = threshold.getRequired("threshold") + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(): Optional = + Optional.ofNullable(expiresAfter.getNullable("expires_after")) + + /** The unit of expires_after. */ + fun expiresAfterUnit(): Optional = + Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) + + /** The amount to increment when the threshold is reached. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The currency or custom pricing unit to use for this top-up. If this is a real-world * currency, it must match the customer's invoicing currency. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") fun invoiceSettings(): InvoiceSettings = invoiceSettings + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") fun perUnitCostBasis(): String = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis /** * The threshold at which to trigger the top-up. If the balance is at or below this * threshold, the top-up will be triggered. */ - @JsonProperty("threshold") fun threshold(): String = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ @JsonProperty("expires_after") - fun expiresAfter(): Optional = Optional.ofNullable(expiresAfter) + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter /** The unit of expires_after. */ @JsonProperty("expires_after_unit") - fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit) + @ExcludeMissing + fun _expiresAfterUnit(): JsonField = expiresAfterUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomerCreditTopUpCreateBody = apply { + if (!validated) { + amount() + currency() + invoiceSettings().validate() + perUnitCostBasis() + threshold() + expiresAfter() + expiresAfterUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -138,13 +244,13 @@ constructor( class Builder { - private var amount: String? = null - private var currency: String? = null - private var invoiceSettings: InvoiceSettings? = null - private var perUnitCostBasis: String? = null - private var threshold: String? = null - private var expiresAfter: Long? = null - private var expiresAfterUnit: ExpiresAfterUnit? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var invoiceSettings: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var threshold: JsonField? = null + private var expiresAfter: JsonField = JsonMissing.of() + private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -162,21 +268,38 @@ constructor( } /** The amount to increment when the threshold is reached. */ - fun amount(amount: String) = apply { this.amount = amount } + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The amount to increment when the threshold is reached. */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** * The currency or custom pricing unit to use for this top-up. If this is a real-world * currency, it must match the customer's invoicing currency. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } /** Settings for invoices generated by triggered top-ups. */ - fun invoiceSettings(invoiceSettings: InvoiceSettings) = apply { + fun invoiceSettings(invoiceSettings: InvoiceSettings) = + invoiceSettings(JsonField.of(invoiceSettings)) + + /** Settings for invoices generated by triggered top-ups. */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { this.invoiceSettings = invoiceSettings } /** How much, in the customer's currency, to charge for each unit. */ - fun perUnitCostBasis(perUnitCostBasis: String) = apply { + fun perUnitCostBasis(perUnitCostBasis: String) = + perUnitCostBasis(JsonField.of(perUnitCostBasis)) + + /** How much, in the customer's currency, to charge for each unit. */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { this.perUnitCostBasis = perUnitCostBasis } @@ -184,13 +307,19 @@ constructor( * The threshold at which to trigger the top-up. If the balance is at or below this * threshold, the top-up will be triggered. */ - fun threshold(threshold: String) = apply { this.threshold = threshold } + fun threshold(threshold: String) = threshold(JsonField.of(threshold)) + + /** + * The threshold at which to trigger the top-up. If the balance is at or below this + * threshold, the top-up will be triggered. + */ + fun threshold(threshold: JsonField) = apply { this.threshold = threshold } /** * The number of days or months after which the top-up expires. If unspecified, it does * not expire. */ - fun expiresAfter(expiresAfter: Long?) = apply { this.expiresAfter = expiresAfter } + fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) /** * The number of days or months after which the top-up expires. If unspecified, it does @@ -206,15 +335,27 @@ constructor( fun expiresAfter(expiresAfter: Optional) = expiresAfter(expiresAfter.orElse(null) as Long?) - /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = apply { - this.expiresAfterUnit = expiresAfterUnit + /** + * The number of days or months after which the top-up expires. If unspecified, it does + * not expire. + */ + fun expiresAfter(expiresAfter: JsonField) = apply { + this.expiresAfter = expiresAfter } + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = + expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) + /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: Optional) = expiresAfterUnit(expiresAfterUnit.orElse(null)) + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { + this.expiresAfterUnit = expiresAfterUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -300,28 +441,53 @@ constructor( /** The amount to increment when the threshold is reached. */ fun amount(amount: String) = apply { body.amount(amount) } + /** The amount to increment when the threshold is reached. */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** * The currency or custom pricing unit to use for this top-up. If this is a real-world * currency, it must match the customer's invoicing currency. */ fun currency(currency: String) = apply { body.currency(currency) } + /** + * The currency or custom pricing unit to use for this top-up. If this is a real-world + * currency, it must match the customer's invoicing currency. + */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** Settings for invoices generated by triggered top-ups. */ fun invoiceSettings(invoiceSettings: InvoiceSettings) = apply { body.invoiceSettings(invoiceSettings) } + /** Settings for invoices generated by triggered top-ups. */ + fun invoiceSettings(invoiceSettings: JsonField) = apply { + body.invoiceSettings(invoiceSettings) + } + /** How much, in the customer's currency, to charge for each unit. */ fun perUnitCostBasis(perUnitCostBasis: String) = apply { body.perUnitCostBasis(perUnitCostBasis) } + /** How much, in the customer's currency, to charge for each unit. */ + fun perUnitCostBasis(perUnitCostBasis: JsonField) = apply { + body.perUnitCostBasis(perUnitCostBasis) + } + /** * The threshold at which to trigger the top-up. If the balance is at or below this * threshold, the top-up will be triggered. */ fun threshold(threshold: String) = apply { body.threshold(threshold) } + /** + * The threshold at which to trigger the top-up. If the balance is at or below this + * threshold, the top-up will be triggered. + */ + fun threshold(threshold: JsonField) = apply { body.threshold(threshold) } + /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. @@ -342,6 +508,12 @@ constructor( fun expiresAfter(expiresAfter: Optional) = expiresAfter(expiresAfter.orElse(null) as Long?) + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(expiresAfter: JsonField) = apply { body.expiresAfter(expiresAfter) } + /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = apply { body.expiresAfterUnit(expiresAfterUnit) @@ -351,6 +523,30 @@ constructor( fun expiresAfterUnit(expiresAfterUnit: Optional) = expiresAfterUnit(expiresAfterUnit.orElse(null)) + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { + body.expiresAfterUnit(expiresAfterUnit) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -449,25 +645,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CustomerCreditTopUpCreateParams = CustomerCreditTopUpCreateParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, @@ -482,10 +659,18 @@ constructor( class InvoiceSettings @JsonCreator private constructor( - @JsonProperty("auto_collection") private val autoCollection: Boolean, - @JsonProperty("net_terms") private val netTerms: Long, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("require_successful_payment") private val requireSuccessfulPayment: Boolean?, + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("require_successful_payment") + @ExcludeMissing + private val requireSuccessfulPayment: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -494,29 +679,65 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") fun autoCollection(): Boolean = autoCollection + fun autoCollection(): Boolean = autoCollection.getRequired("auto_collection") /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") fun netTerms(): Long = netTerms + fun netTerms(): Long = netTerms.getRequired("net_terms") /** An optional memo to display on the invoice. */ - @JsonProperty("memo") fun memo(): Optional = Optional.ofNullable(memo) + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) /** * If true, new credit blocks created by this top-up will require that the corresponding * invoice is paid before they can be drawn down from. */ - @JsonProperty("require_successful_payment") fun requireSuccessfulPayment(): Optional = - Optional.ofNullable(requireSuccessfulPayment) + Optional.ofNullable(requireSuccessfulPayment.getNullable("require_successful_payment")) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection + + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms + + /** An optional memo to display on the invoice. */ + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo + + /** + * If true, new credit blocks created by this top-up will require that the corresponding + * invoice is paid before they can be drawn down from. + */ + @JsonProperty("require_successful_payment") + @ExcludeMissing + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceSettings = apply { + if (!validated) { + autoCollection() + netTerms() + memo() + requireSuccessfulPayment() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -526,10 +747,10 @@ constructor( class Builder { - private var autoCollection: Boolean? = null - private var netTerms: Long? = null - private var memo: String? = null - private var requireSuccessfulPayment: Boolean? = null + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null + private var memo: JsonField = JsonMissing.of() + private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -545,7 +766,14 @@ constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - fun autoCollection(autoCollection: Boolean) = apply { + fun autoCollection(autoCollection: Boolean) = + autoCollection(JsonField.of(autoCollection)) + + /** + * Whether the credits purchase invoice should auto collect with the customer's saved + * payment method. + */ + fun autoCollection(autoCollection: JsonField) = apply { this.autoCollection = autoCollection } @@ -553,36 +781,37 @@ constructor( * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. */ - fun netTerms(netTerms: Long) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** An optional memo to display on the invoice. */ fun memo(memo: Optional) = memo(memo.orElse(null)) - /** - * If true, new credit blocks created by this top-up will require that the corresponding - * invoice is paid before they can be drawn down from. - */ - fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean?) = apply { - this.requireSuccessfulPayment = requireSuccessfulPayment - } + /** An optional memo to display on the invoice. */ + fun memo(memo: JsonField) = apply { this.memo = memo } /** * If true, new credit blocks created by this top-up will require that the corresponding * invoice is paid before they can be drawn down from. */ fun requireSuccessfulPayment(requireSuccessfulPayment: Boolean) = - requireSuccessfulPayment(requireSuccessfulPayment as Boolean?) + requireSuccessfulPayment(JsonField.of(requireSuccessfulPayment)) /** * If true, new credit blocks created by this top-up will require that the corresponding * invoice is paid before they can be drawn down from. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun requireSuccessfulPayment(requireSuccessfulPayment: Optional) = - requireSuccessfulPayment(requireSuccessfulPayment.orElse(null) as Boolean?) + fun requireSuccessfulPayment(requireSuccessfulPayment: JsonField) = apply { + this.requireSuccessfulPayment = requireSuccessfulPayment + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt index 914d16d6..f60627af 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpCreateResponse.kt @@ -81,37 +81,45 @@ private constructor( fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, * it must match the customer's invoicing currency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") @ExcludeMissing fun _invoiceSettings() = invoiceSettings + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") @ExcludeMissing fun _perUnitCostBasis() = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis /** * The threshold at which to trigger the top-up. If the balance is at or below this threshold, * the top-up will be triggered. */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold() = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - @JsonProperty("expires_after") @ExcludeMissing fun _expiresAfter() = expiresAfter + @JsonProperty("expires_after") + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") @ExcludeMissing fun _expiresAfterUnit() = expiresAfterUnit + @JsonProperty("expires_after_unit") + @ExcludeMissing + fun _expiresAfterUnit(): JsonField = expiresAfterUnit @JsonAnyGetter @ExcludeMissing @@ -142,12 +150,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var invoiceSettings: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var threshold: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var invoiceSettings: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var threshold: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -223,7 +231,21 @@ private constructor( * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(JsonField.of(expiresAfter)) + fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun expiresAfter(expiresAfter: Optional) = + expiresAfter(expiresAfter.orElse(null) as Long?) /** * The number of days or months after which the top-up expires. If unspecified, it does not @@ -232,8 +254,12 @@ private constructor( fun expiresAfter(expiresAfter: JsonField) = apply { this.expiresAfter = expiresAfter } /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit) = - expiresAfterUnit(JsonField.of(expiresAfterUnit)) + fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = + expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) + + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: Optional) = + expiresAfterUnit(expiresAfterUnit.orElse(null)) /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { @@ -261,12 +287,12 @@ private constructor( fun build(): CustomerCreditTopUpCreateResponse = CustomerCreditTopUpCreateResponse( - id, - amount, - currency, - invoiceSettings, - perUnitCostBasis, - threshold, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(invoiceSettings) { "`invoiceSettings` is required but was not set" }, + checkNotNull(perUnitCostBasis) { "`perUnitCostBasis` is required but was not set" }, + checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, additionalProperties.toImmutable(), @@ -320,16 +346,18 @@ private constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * If true, new credit blocks created by this top-up will require that the corresponding @@ -337,7 +365,7 @@ private constructor( */ @JsonProperty("require_successful_payment") @ExcludeMissing - fun _requireSuccessfulPayment() = requireSuccessfulPayment + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing @@ -364,8 +392,8 @@ private constructor( class Builder { - private var autoCollection: JsonField = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -407,7 +435,10 @@ private constructor( fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo to display on the invoice. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo to display on the invoice. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -448,8 +479,8 @@ private constructor( fun build(): InvoiceSettings = InvoiceSettings( - autoCollection, - netTerms, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, additionalProperties.toImmutable(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt index c0113576..dca573a5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteByExternalIdParams.kt @@ -10,6 +10,7 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** Delete top-up by external ID */ class CustomerCreditTopUpDeleteByExternalIdParams constructor( private val externalCustomerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt index 76e318bf..b62ea533 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpDeleteParams.kt @@ -10,6 +10,7 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** Delete top-up */ class CustomerCreditTopUpDeleteParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt index 15040e73..8908293c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdParams.kt @@ -8,6 +8,7 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** List top-ups by external ID */ class CustomerCreditTopUpListByExternalIdParams constructor( private val externalCustomerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt index 952e4837..58eba3f0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListByExternalIdResponse.kt @@ -81,37 +81,45 @@ private constructor( fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, * it must match the customer's invoicing currency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") @ExcludeMissing fun _invoiceSettings() = invoiceSettings + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") @ExcludeMissing fun _perUnitCostBasis() = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis /** * The threshold at which to trigger the top-up. If the balance is at or below this threshold, * the top-up will be triggered. */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold() = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - @JsonProperty("expires_after") @ExcludeMissing fun _expiresAfter() = expiresAfter + @JsonProperty("expires_after") + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") @ExcludeMissing fun _expiresAfterUnit() = expiresAfterUnit + @JsonProperty("expires_after_unit") + @ExcludeMissing + fun _expiresAfterUnit(): JsonField = expiresAfterUnit @JsonAnyGetter @ExcludeMissing @@ -142,12 +150,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var invoiceSettings: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var threshold: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var invoiceSettings: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var threshold: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -224,7 +232,21 @@ private constructor( * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(JsonField.of(expiresAfter)) + fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun expiresAfter(expiresAfter: Optional) = + expiresAfter(expiresAfter.orElse(null) as Long?) /** * The number of days or months after which the top-up expires. If unspecified, it does not @@ -233,8 +255,12 @@ private constructor( fun expiresAfter(expiresAfter: JsonField) = apply { this.expiresAfter = expiresAfter } /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit) = - expiresAfterUnit(JsonField.of(expiresAfterUnit)) + fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = + expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) + + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: Optional) = + expiresAfterUnit(expiresAfterUnit.orElse(null)) /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { @@ -262,12 +288,12 @@ private constructor( fun build(): CustomerCreditTopUpListByExternalIdResponse = CustomerCreditTopUpListByExternalIdResponse( - id, - amount, - currency, - invoiceSettings, - perUnitCostBasis, - threshold, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(invoiceSettings) { "`invoiceSettings` is required but was not set" }, + checkNotNull(perUnitCostBasis) { "`perUnitCostBasis` is required but was not set" }, + checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, additionalProperties.toImmutable(), @@ -321,16 +347,18 @@ private constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * If true, new credit blocks created by this top-up will require that the corresponding @@ -338,7 +366,7 @@ private constructor( */ @JsonProperty("require_successful_payment") @ExcludeMissing - fun _requireSuccessfulPayment() = requireSuccessfulPayment + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing @@ -365,8 +393,8 @@ private constructor( class Builder { - private var autoCollection: JsonField = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -408,7 +436,10 @@ private constructor( fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo to display on the invoice. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo to display on the invoice. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -449,8 +480,8 @@ private constructor( fun build(): InvoiceSettings = InvoiceSettings( - autoCollection, - netTerms, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, additionalProperties.toImmutable(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt index 463a12d2..028efb01 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListParams.kt @@ -8,6 +8,7 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** List top-ups */ class CustomerCreditTopUpListParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt index 1822b168..d229bc4e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerCreditTopUpListResponse.kt @@ -81,37 +81,45 @@ private constructor( fun expiresAfterUnit(): Optional = Optional.ofNullable(expiresAfterUnit.getNullable("expires_after_unit")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount to increment when the threshold is reached. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** * The currency or custom pricing unit to use for this top-up. If this is a real-world currency, * it must match the customer's invoicing currency. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** Settings for invoices generated by triggered top-ups. */ - @JsonProperty("invoice_settings") @ExcludeMissing fun _invoiceSettings() = invoiceSettings + @JsonProperty("invoice_settings") + @ExcludeMissing + fun _invoiceSettings(): JsonField = invoiceSettings /** How much, in the customer's currency, to charge for each unit. */ - @JsonProperty("per_unit_cost_basis") @ExcludeMissing fun _perUnitCostBasis() = perUnitCostBasis + @JsonProperty("per_unit_cost_basis") + @ExcludeMissing + fun _perUnitCostBasis(): JsonField = perUnitCostBasis /** * The threshold at which to trigger the top-up. If the balance is at or below this threshold, * the top-up will be triggered. */ - @JsonProperty("threshold") @ExcludeMissing fun _threshold() = threshold + @JsonProperty("threshold") @ExcludeMissing fun _threshold(): JsonField = threshold /** * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - @JsonProperty("expires_after") @ExcludeMissing fun _expiresAfter() = expiresAfter + @JsonProperty("expires_after") + @ExcludeMissing + fun _expiresAfter(): JsonField = expiresAfter /** The unit of expires_after. */ - @JsonProperty("expires_after_unit") @ExcludeMissing fun _expiresAfterUnit() = expiresAfterUnit + @JsonProperty("expires_after_unit") + @ExcludeMissing + fun _expiresAfterUnit(): JsonField = expiresAfterUnit @JsonAnyGetter @ExcludeMissing @@ -142,12 +150,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var invoiceSettings: JsonField = JsonMissing.of() - private var perUnitCostBasis: JsonField = JsonMissing.of() - private var threshold: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var currency: JsonField? = null + private var invoiceSettings: JsonField? = null + private var perUnitCostBasis: JsonField? = null + private var threshold: JsonField? = null private var expiresAfter: JsonField = JsonMissing.of() private var expiresAfterUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -223,7 +231,21 @@ private constructor( * The number of days or months after which the top-up expires. If unspecified, it does not * expire. */ - fun expiresAfter(expiresAfter: Long) = expiresAfter(JsonField.of(expiresAfter)) + fun expiresAfter(expiresAfter: Long?) = expiresAfter(JsonField.ofNullable(expiresAfter)) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + fun expiresAfter(expiresAfter: Long) = expiresAfter(expiresAfter as Long?) + + /** + * The number of days or months after which the top-up expires. If unspecified, it does not + * expire. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun expiresAfter(expiresAfter: Optional) = + expiresAfter(expiresAfter.orElse(null) as Long?) /** * The number of days or months after which the top-up expires. If unspecified, it does not @@ -232,8 +254,12 @@ private constructor( fun expiresAfter(expiresAfter: JsonField) = apply { this.expiresAfter = expiresAfter } /** The unit of expires_after. */ - fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit) = - expiresAfterUnit(JsonField.of(expiresAfterUnit)) + fun expiresAfterUnit(expiresAfterUnit: ExpiresAfterUnit?) = + expiresAfterUnit(JsonField.ofNullable(expiresAfterUnit)) + + /** The unit of expires_after. */ + fun expiresAfterUnit(expiresAfterUnit: Optional) = + expiresAfterUnit(expiresAfterUnit.orElse(null)) /** The unit of expires_after. */ fun expiresAfterUnit(expiresAfterUnit: JsonField) = apply { @@ -261,12 +287,12 @@ private constructor( fun build(): CustomerCreditTopUpListResponse = CustomerCreditTopUpListResponse( - id, - amount, - currency, - invoiceSettings, - perUnitCostBasis, - threshold, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(invoiceSettings) { "`invoiceSettings` is required but was not set" }, + checkNotNull(perUnitCostBasis) { "`perUnitCostBasis` is required but was not set" }, + checkNotNull(threshold) { "`threshold` is required but was not set" }, expiresAfter, expiresAfterUnit, additionalProperties.toImmutable(), @@ -320,16 +346,18 @@ private constructor( * Whether the credits purchase invoice should auto collect with the customer's saved * payment method. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** An optional memo to display on the invoice. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * If true, new credit blocks created by this top-up will require that the corresponding @@ -337,7 +365,7 @@ private constructor( */ @JsonProperty("require_successful_payment") @ExcludeMissing - fun _requireSuccessfulPayment() = requireSuccessfulPayment + fun _requireSuccessfulPayment(): JsonField = requireSuccessfulPayment @JsonAnyGetter @ExcludeMissing @@ -364,8 +392,8 @@ private constructor( class Builder { - private var autoCollection: JsonField = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() + private var autoCollection: JsonField? = null + private var netTerms: JsonField? = null private var memo: JsonField = JsonMissing.of() private var requireSuccessfulPayment: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -407,7 +435,10 @@ private constructor( fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** An optional memo to display on the invoice. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo to display on the invoice. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo to display on the invoice. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -448,8 +479,8 @@ private constructor( fun build(): InvoiceSettings = InvoiceSettings( - autoCollection, - netTerms, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, memo, requireSuccessfulPayment, additionalProperties.toImmutable(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt index 63ecd62c..14241f42 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerDeleteParams.kt @@ -10,6 +10,20 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This performs a deletion of this customer, its subscriptions, and its invoices, provided the + * customer does not have any issued invoices. Customers with issued invoices cannot be deleted. + * This operation is irreversible. Note that this is a _soft_ deletion, but the data will be + * inaccessible through the API and Orb dashboard. For a hard-deletion, please reach out to the Orb + * team directly. + * + * **Note**: This operation happens asynchronously and can be expected to take a few minutes to + * propagate to related resources. However, querying for the customer on subsequent GET requests + * while deletion is in process will reflect its deletion with a `deleted: true` property. Once the + * customer deletion has been fully processed, the customer will not be returned in the API. + * + * On successful processing, this returns an empty dictionary (`{}`) in the API. + */ class CustomerDeleteParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt index c08aec62..37ad269c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchByExternalIdParams.kt @@ -7,6 +7,13 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch customer details given an `external_customer_id` (see + * [Customer ID Aliases](../guides/events-and-metrics/customer-aliases)). + * + * Note that the resource and semantics of this endpoint exactly mirror + * [Get Customer](fetch-customer). + */ class CustomerFetchByExternalIdParams constructor( private val externalCustomerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt index 854ccfbc..e486a4a2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerFetchParams.kt @@ -7,6 +7,13 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch customer details given an identifier. If the `Customer` is in the + * process of being deleted, only the properties `id` and `deleted: true` will be returned. + * + * See the [Customer resource](../guides/core-concepts.mdx#customer) for a full discussion of the + * Customer model. + */ class CustomerFetchParams constructor( private val customerId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt index 376b6f2e..f95e2248 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerListParams.kt @@ -10,6 +10,13 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all customers for an account. The list of customers is ordered + * starting from the most recently created customer. This endpoint follows Orb's + * [standardized pagination format](../reference/pagination). + * + * See [Customer](../guides/concepts#customer) for an overview of the customer model. + */ class CustomerListParams constructor( private val createdAtGt: OffsetDateTime?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt index 2b6ff818..e2583cf4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateByExternalIdParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,11 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint is used to update customer details given an `external_customer_id` (see + * [Customer ID Aliases](../guides/events-and-metrics/customer-aliases)). Note that the resource and + * semantics of this endpoint exactly mirror [Update Customer](update-customer). + */ class CustomerUpdateByExternalIdParams constructor( private val id: String, @@ -214,12 +220,187 @@ constructor( */ fun taxId(): Optional = body.taxId() - fun _additionalHeaders(): Headers = additionalHeaders + fun _accountingSyncConfiguration(): JsonField = + body._accountingSyncConfiguration() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun _additionalEmails(): JsonField> = body._additionalEmails() + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a saved + * payment method, if available. This parameter defaults to `True` when a payment provider is + * provided on customer creation. + */ + fun _autoCollection(): JsonField = body._autoCollection() + + fun _billingAddress(): JsonField = body._billingAddress() + + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun _currency(): JsonField = body._currency() + + /** A valid customer email, to be used for invoicing and notifications. */ + fun _email(): JsonField = body._email() + + fun _emailDelivery(): JsonField = body._emailDelivery() + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** The full name of the customer */ + fun _name(): JsonField = body._name() + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun _paymentProvider(): JsonField = body._paymentProvider() + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + fun _paymentProviderId(): JsonField = body._paymentProviderId() + + fun _reportingConfiguration(): JsonField = + body._reportingConfiguration() + + fun _shippingAddress(): JsonField = body._shippingAddress() + + fun _taxConfiguration(): JsonField = body._taxConfiguration() + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to the + * headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun _taxId(): JsonField = body._taxId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CustomerUpdateByExternalIdBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -238,37 +419,256 @@ constructor( @JsonCreator internal constructor( @JsonProperty("accounting_sync_configuration") - private val accountingSyncConfiguration: AccountingSyncConfiguration?, - @JsonProperty("additional_emails") private val additionalEmails: List?, - @JsonProperty("auto_collection") private val autoCollection: Boolean?, - @JsonProperty("billing_address") private val billingAddress: BillingAddress?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("email") private val email: String?, - @JsonProperty("email_delivery") private val emailDelivery: Boolean?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("name") private val name: String?, - @JsonProperty("payment_provider") private val paymentProvider: PaymentProvider?, - @JsonProperty("payment_provider_id") private val paymentProviderId: String?, + @ExcludeMissing + private val accountingSyncConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("additional_emails") + @ExcludeMissing + private val additionalEmails: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + private val billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + private val email: JsonField = JsonMissing.of(), + @JsonProperty("email_delivery") + @ExcludeMissing + private val emailDelivery: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + private val paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + private val paymentProviderId: JsonField = JsonMissing.of(), @JsonProperty("reporting_configuration") - private val reportingConfiguration: ReportingConfiguration?, - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress?, - @JsonProperty("tax_configuration") private val taxConfiguration: TaxConfiguration?, - @JsonProperty("tax_id") private val taxId: TaxId?, + @ExcludeMissing + private val reportingConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("tax_configuration") + @ExcludeMissing + private val taxConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("tax_id") + @ExcludeMissing + private val taxId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun accountingSyncConfiguration(): Optional = + Optional.ofNullable( + accountingSyncConfiguration.getNullable("accounting_sync_configuration") + ) + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(): Optional> = + Optional.ofNullable(additionalEmails.getNullable("additional_emails")) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun billingAddress(): Optional = + Optional.ofNullable(billingAddress.getNullable("billing_address")) + + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(): Optional = Optional.ofNullable(email.getNullable("email")) + + fun emailDelivery(): Optional = + Optional.ofNullable(emailDelivery.getNullable("email_delivery")) + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The full name of the customer */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(): Optional = + Optional.ofNullable(paymentProvider.getNullable("payment_provider")) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(): Optional = + Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) + + fun reportingConfiguration(): Optional = + Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) + + fun shippingAddress(): Optional = + Optional.ofNullable(shippingAddress.getNullable("shipping_address")) + + fun taxConfiguration(): Optional = + Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + @JsonProperty("accounting_sync_configuration") - fun accountingSyncConfiguration(): Optional = - Optional.ofNullable(accountingSyncConfiguration) + @ExcludeMissing + fun _accountingSyncConfiguration(): JsonField = + accountingSyncConfiguration /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. */ @JsonProperty("additional_emails") - fun additionalEmails(): Optional> = Optional.ofNullable(additionalEmails) + @ExcludeMissing + fun _additionalEmails(): JsonField> = additionalEmails /** * Used to determine if invoices for this customer will automatically attempt to charge a @@ -276,39 +676,43 @@ constructor( * provider is provided on customer creation. */ @JsonProperty("auto_collection") - fun autoCollection(): Optional = Optional.ofNullable(autoCollection) + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_address") - fun billingAddress(): Optional = Optional.ofNullable(billingAddress) + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at * creation time, will be set at subscription creation time. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A valid customer email, to be used for invoicing and notifications. */ - @JsonProperty("email") fun email(): Optional = Optional.ofNullable(email) + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email @JsonProperty("email_delivery") - fun emailDelivery(): Optional = Optional.ofNullable(emailDelivery) + @ExcludeMissing + fun _emailDelivery(): JsonField = emailDelivery /** * The external customer ID. This can only be set if empty and the customer has no past or * current subscriptions. */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The full name of the customer */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * This is used for creating charges or invoices in an external system via Orb. When not in @@ -318,24 +722,28 @@ constructor( * `netsuite`), any product mappings must first be configured with the Orb team. */ @JsonProperty("payment_provider") - fun paymentProvider(): Optional = Optional.ofNullable(paymentProvider) + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider /** * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ @JsonProperty("payment_provider_id") - fun paymentProviderId(): Optional = Optional.ofNullable(paymentProviderId) + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId @JsonProperty("reporting_configuration") - fun reportingConfiguration(): Optional = - Optional.ofNullable(reportingConfiguration) + @ExcludeMissing + fun _reportingConfiguration(): JsonField = reportingConfiguration @JsonProperty("shipping_address") - fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress) + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress @JsonProperty("tax_configuration") - fun taxConfiguration(): Optional = Optional.ofNullable(taxConfiguration) + @ExcludeMissing + fun _taxConfiguration(): JsonField = taxConfiguration /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -443,12 +851,36 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("tax_id") fun taxId(): Optional = Optional.ofNullable(taxId) + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomerUpdateByExternalIdBody = apply { + if (!validated) { + accountingSyncConfiguration().map { it.validate() } + additionalEmails() + autoCollection() + billingAddress().map { it.validate() } + currency() + email() + emailDelivery() + externalCustomerId() + metadata().map { it.validate() } + name() + paymentProvider() + paymentProviderId() + reportingConfiguration().map { it.validate() } + shippingAddress().map { it.validate() } + taxConfiguration() + taxId().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -458,22 +890,23 @@ constructor( class Builder { - private var accountingSyncConfiguration: AccountingSyncConfiguration? = null - private var additionalEmails: MutableList? = null - private var autoCollection: Boolean? = null - private var billingAddress: BillingAddress? = null - private var currency: String? = null - private var email: String? = null - private var emailDelivery: Boolean? = null - private var externalCustomerId: String? = null - private var metadata: Metadata? = null - private var name: String? = null - private var paymentProvider: PaymentProvider? = null - private var paymentProviderId: String? = null - private var reportingConfiguration: ReportingConfiguration? = null - private var shippingAddress: ShippingAddress? = null - private var taxConfiguration: TaxConfiguration? = null - private var taxId: TaxId? = null + private var accountingSyncConfiguration: JsonField = + JsonMissing.of() + private var additionalEmails: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() + private var billingAddress: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var emailDelivery: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var paymentProvider: JsonField = JsonMissing.of() + private var paymentProviderId: JsonField = JsonMissing.of() + private var reportingConfiguration: JsonField = JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var taxConfiguration: JsonField = JsonMissing.of() + private var taxId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -482,7 +915,7 @@ constructor( accountingSyncConfiguration = customerUpdateByExternalIdBody.accountingSyncConfiguration additionalEmails = - customerUpdateByExternalIdBody.additionalEmails?.toMutableList() + customerUpdateByExternalIdBody.additionalEmails.map { it.toMutableList() } autoCollection = customerUpdateByExternalIdBody.autoCollection billingAddress = customerUpdateByExternalIdBody.billingAddress currency = customerUpdateByExternalIdBody.currency @@ -503,19 +936,22 @@ constructor( fun accountingSyncConfiguration( accountingSyncConfiguration: AccountingSyncConfiguration? - ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) fun accountingSyncConfiguration( accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + /** * Additional email addresses for this customer. If populated, these email addresses * will be CC'd for customer communications. */ - fun additionalEmails(additionalEmails: List?) = apply { - this.additionalEmails = additionalEmails?.toMutableList() - } + fun additionalEmails(additionalEmails: List?) = + additionalEmails(JsonField.ofNullable(additionalEmails)) /** * Additional email addresses for this customer. If populated, these email addresses @@ -524,13 +960,29 @@ constructor( fun additionalEmails(additionalEmails: Optional>) = additionalEmails(additionalEmails.orElse(null)) + /** + * Additional email addresses for this customer. If populated, these email addresses + * will be CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + this.additionalEmails = additionalEmails.map { it.toMutableList() } + } + /** * Additional email addresses for this customer. If populated, these email addresses * will be CC'd for customer communications. */ fun addAdditionalEmail(additionalEmail: String) = apply { additionalEmails = - (additionalEmails ?: mutableListOf()).apply { add(additionalEmail) } + (additionalEmails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(additionalEmail) + } } /** @@ -538,9 +990,8 @@ constructor( * a saved payment method, if available. This parameter defaults to `True` when a * payment provider is provided on customer creation. */ - fun autoCollection(autoCollection: Boolean?) = apply { - this.autoCollection = autoCollection - } + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) /** * Used to determine if invoices for this customer will automatically attempt to charge @@ -558,18 +1009,30 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) - fun billingAddress(billingAddress: BillingAddress?) = apply { - this.billingAddress = billingAddress + /** + * Used to determine if invoices for this customer will automatically attempt to charge + * a saved payment method, if available. This parameter defaults to `True` when a + * payment provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection } + fun billingAddress(billingAddress: BillingAddress?) = + billingAddress(JsonField.ofNullable(billingAddress)) + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = billingAddress + } + /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set * at creation time, will be set at subscription creation time. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set @@ -577,15 +1040,23 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set + * at creation time, will be set at subscription creation time. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: String?) = apply { this.email = email } + fun email(email: String?) = email(JsonField.ofNullable(email)) /** A valid customer email, to be used for invoicing and notifications. */ fun email(email: Optional) = email(email.orElse(null)) - fun emailDelivery(emailDelivery: Boolean?) = apply { - this.emailDelivery = emailDelivery - } + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: JsonField) = apply { this.email = email } + + fun emailDelivery(emailDelivery: Boolean?) = + emailDelivery(JsonField.ofNullable(emailDelivery)) fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) @@ -593,13 +1064,16 @@ constructor( fun emailDelivery(emailDelivery: Optional) = emailDelivery(emailDelivery.orElse(null) as Boolean?) + fun emailDelivery(emailDelivery: JsonField) = apply { + this.emailDelivery = emailDelivery + } + /** * The external customer ID. This can only be set if empty and the customer has no past * or current subscriptions. */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * The external customer ID. This can only be set if empty and the customer has no past @@ -608,12 +1082,20 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * The external customer ID. This can only be set if empty and the customer has no past + * or current subscriptions. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -622,12 +1104,22 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** The full name of the customer */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The full name of the customer */ fun name(name: Optional) = name(name.orElse(null)) + /** The full name of the customer */ + fun name(name: JsonField) = apply { this.name = name } + /** * This is used for creating charges or invoices in an external system via Orb. When not * in test mode: @@ -636,9 +1128,8 @@ constructor( * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb * team. */ - fun paymentProvider(paymentProvider: PaymentProvider?) = apply { - this.paymentProvider = paymentProvider - } + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) /** * This is used for creating charges or invoices in an external system via Orb. When not @@ -651,54 +1142,188 @@ constructor( fun paymentProvider(paymentProvider: Optional) = paymentProvider(paymentProvider.orElse(null)) + /** + * This is used for creating charges or invoices in an external system via Orb. When not + * in test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, + * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb + * team. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + /** * The ID of this customer in an external payments solution, such as Stripe. This is * used for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: String?) = apply { - this.paymentProviderId = paymentProviderId - } + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is + * used for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) /** * The ID of this customer in an external payments solution, such as Stripe. This is * used for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - this.reportingConfiguration = reportingConfiguration - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - this.shippingAddress = shippingAddress - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - this.taxConfiguration = taxConfiguration - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration( - newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration - ) = apply { - this.taxConfiguration = - TaxConfiguration.ofNewAvalaraTaxConfiguration(newAvalaraTaxConfiguration) - } - - fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = - apply { - this.taxConfiguration = - TaxConfiguration.ofNewTaxJarConfiguration(newTaxJarConfiguration) - } + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = + reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + this.reportingConfiguration = reportingConfiguration + } + + fun shippingAddress(shippingAddress: ShippingAddress?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + fun taxConfiguration(taxConfiguration: TaxConfiguration?) = + taxConfiguration(JsonField.ofNullable(taxConfiguration)) + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + this.taxConfiguration = taxConfiguration + } + + fun taxConfiguration( + newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration + ) = + taxConfiguration( + TaxConfiguration.ofNewAvalaraTaxConfiguration(newAvalaraTaxConfiguration) + ) + + fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = + taxConfiguration(TaxConfiguration.ofNewTaxJarConfiguration(newTaxJarConfiguration)) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added + * to the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -806,7 +1431,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { this.taxId = taxId } + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -914,7 +1539,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -938,7 +1563,7 @@ constructor( fun build(): CustomerUpdateByExternalIdBody = CustomerUpdateByExternalIdBody( accountingSyncConfiguration, - additionalEmails?.toImmutable(), + (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, billingAddress, currency, @@ -1012,6 +1637,10 @@ constructor( accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } + /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. @@ -1027,6 +1656,14 @@ constructor( fun additionalEmails(additionalEmails: Optional>) = additionalEmails(additionalEmails.orElse(null)) + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + body.additionalEmails(additionalEmails) + } + /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. @@ -1058,6 +1695,15 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + fun billingAddress(billingAddress: BillingAddress?) = apply { body.billingAddress(billingAddress) } @@ -1065,6 +1711,10 @@ constructor( fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) + fun billingAddress(billingAddress: JsonField) = apply { + body.billingAddress(billingAddress) + } + /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at * creation time, will be set at subscription creation time. @@ -1077,12 +1727,21 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** A valid customer email, to be used for invoicing and notifications. */ fun email(email: String?) = apply { body.email(email) } /** A valid customer email, to be used for invoicing and notifications. */ fun email(email: Optional) = email(email.orElse(null)) + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: JsonField) = apply { body.email(email) } + fun emailDelivery(emailDelivery: Boolean?) = apply { body.emailDelivery(emailDelivery) } fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) @@ -1091,6 +1750,10 @@ constructor( fun emailDelivery(emailDelivery: Optional) = emailDelivery(emailDelivery.orElse(null) as Boolean?) + fun emailDelivery(emailDelivery: JsonField) = apply { + body.emailDelivery(emailDelivery) + } + /** * The external customer ID. This can only be set if empty and the customer has no past or * current subscriptions. @@ -1106,6 +1769,14 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -1120,12 +1791,22 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** The full name of the customer */ fun name(name: String?) = apply { body.name(name) } /** The full name of the customer */ fun name(name: Optional) = name(name.orElse(null)) + /** The full name of the customer */ + fun name(name: JsonField) = apply { body.name(name) } + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode: @@ -1147,6 +1828,17 @@ constructor( fun paymentProvider(paymentProvider: Optional) = paymentProvider(paymentProvider.orElse(null)) + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + body.paymentProvider(paymentProvider) + } + /** * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. @@ -1159,38 +1851,167 @@ constructor( * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - body.shippingAddress(shippingAddress) - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration( - newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration - ) = apply { body.taxConfiguration(newAvalaraTaxConfiguration) } - - fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = - apply { - body.taxConfiguration(newTaxJarConfiguration) - } + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + body.paymentProviderId(paymentProviderId) + } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { + body.reportingConfiguration(reportingConfiguration) + } + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + body.reportingConfiguration(reportingConfiguration) + } + + fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + body.shippingAddress(shippingAddress) + } + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + body.shippingAddress(shippingAddress) + } + + fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { + body.taxConfiguration(taxConfiguration) + } + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + body.taxConfiguration(taxConfiguration) + } + + fun taxConfiguration( + newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration + ) = apply { body.taxConfiguration(newAvalaraTaxConfiguration) } + + fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = + apply { + body.taxConfiguration(newTaxJarConfiguration) + } + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1298,7 +2119,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1406,7 +2227,26 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -1506,25 +2346,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CustomerUpdateByExternalIdParams = CustomerUpdateByExternalIdParams( checkNotNull(id) { "`id` is required but was not set" }, @@ -1539,22 +2360,40 @@ constructor( @JsonCreator private constructor( @JsonProperty("accounting_providers") - private val accountingProviders: List?, - @JsonProperty("excluded") private val excluded: Boolean?, + @ExcludeMissing + private val accountingProviders: JsonField> = JsonMissing.of(), + @JsonProperty("excluded") + @ExcludeMissing + private val excluded: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("accounting_providers") fun accountingProviders(): Optional> = - Optional.ofNullable(accountingProviders) + Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) + + fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) + + @JsonProperty("accounting_providers") + @ExcludeMissing + fun _accountingProviders(): JsonField> = accountingProviders - @JsonProperty("excluded") fun excluded(): Optional = Optional.ofNullable(excluded) + @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountingSyncConfiguration = apply { + if (!validated) { + accountingProviders().map { it.forEach { it.validate() } } + excluded() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1564,38 +2403,52 @@ constructor( class Builder { - private var accountingProviders: MutableList? = null - private var excluded: Boolean? = null + private var accountingProviders: JsonField>? = null + private var excluded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { accountingProviders = - accountingSyncConfiguration.accountingProviders?.toMutableList() + accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } excluded = accountingSyncConfiguration.excluded additionalProperties = accountingSyncConfiguration.additionalProperties.toMutableMap() } - fun accountingProviders(accountingProviders: List?) = apply { - this.accountingProviders = accountingProviders?.toMutableList() - } + fun accountingProviders(accountingProviders: List?) = + accountingProviders(JsonField.ofNullable(accountingProviders)) fun accountingProviders(accountingProviders: Optional>) = accountingProviders(accountingProviders.orElse(null)) + fun accountingProviders(accountingProviders: JsonField>) = + apply { + this.accountingProviders = accountingProviders.map { it.toMutableList() } + } + fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { accountingProviders = - (accountingProviders ?: mutableListOf()).apply { add(accountingProvider) } + (accountingProviders ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(accountingProvider) + } } - fun excluded(excluded: Boolean?) = apply { this.excluded = excluded } + fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) + fun excluded(excluded: JsonField) = apply { this.excluded = excluded } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1617,7 +2470,7 @@ constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( - accountingProviders?.toImmutable(), + (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, excluded, additionalProperties.toImmutable(), ) @@ -1627,21 +2480,43 @@ constructor( class AccountingProvider @JsonCreator private constructor( - @JsonProperty("external_provider_id") private val externalProviderId: String, - @JsonProperty("provider_type") private val providerType: String, + @JsonProperty("external_provider_id") + @ExcludeMissing + private val externalProviderId: JsonField = JsonMissing.of(), + @JsonProperty("provider_type") + @ExcludeMissing + private val providerType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun externalProviderId(): String = + externalProviderId.getRequired("external_provider_id") + + fun providerType(): String = providerType.getRequired("provider_type") + @JsonProperty("external_provider_id") - fun externalProviderId(): String = externalProviderId + @ExcludeMissing + fun _externalProviderId(): JsonField = externalProviderId - @JsonProperty("provider_type") fun providerType(): String = providerType + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountingProvider = apply { + if (!validated) { + externalProviderId() + providerType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1651,8 +2526,8 @@ constructor( class Builder { - private var externalProviderId: String? = null - private var providerType: String? = null + private var externalProviderId: JsonField? = null + private var providerType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1662,11 +2537,18 @@ constructor( additionalProperties = accountingProvider.additionalProperties.toMutableMap() } - fun externalProviderId(externalProviderId: String) = apply { + fun externalProviderId(externalProviderId: String) = + externalProviderId(JsonField.of(externalProviderId)) + + fun externalProviderId(externalProviderId: JsonField) = apply { this.externalProviderId = externalProviderId } - fun providerType(providerType: String) = apply { this.providerType = providerType } + fun providerType(providerType: String) = providerType(JsonField.of(providerType)) + + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1740,33 +2622,73 @@ constructor( class BillingAddress @JsonCreator private constructor( - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("line1") private val line1: String?, - @JsonProperty("line2") private val line2: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") + @ExcludeMissing + private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") + @ExcludeMissing + private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("city") fun city(): Optional = Optional.ofNullable(city) + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) + + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) + + fun postalCode(): Optional = + Optional.ofNullable(postalCode.getNullable("postal_code")) - @JsonProperty("country") fun country(): Optional = Optional.ofNullable(country) + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("line1") fun line1(): Optional = Optional.ofNullable(line1) + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("line2") fun line2(): Optional = Optional.ofNullable(line2) + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 @JsonProperty("postal_code") - fun postalCode(): Optional = Optional.ofNullable(postalCode) + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") fun state(): Optional = Optional.ofNullable(state) + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingAddress = apply { + if (!validated) { + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1776,12 +2698,12 @@ constructor( class Builder { - private var city: String? = null - private var country: String? = null - private var line1: String? = null - private var line2: String? = null - private var postalCode: String? = null - private var state: String? = null + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1795,30 +2717,42 @@ constructor( additionalProperties = billingAddress.additionalProperties.toMutableMap() } - fun city(city: String?) = apply { this.city = city } + fun city(city: String?) = city(JsonField.ofNullable(city)) fun city(city: Optional) = city(city.orElse(null)) - fun country(country: String?) = apply { this.country = country } + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) fun country(country: Optional) = country(country.orElse(null)) - fun line1(line1: String?) = apply { this.line1 = line1 } + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) fun line1(line1: Optional) = line1(line1.orElse(null)) - fun line2(line2: String?) = apply { this.line2 = line2 } + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) fun line2(line2: Optional) = line2(line2.orElse(null)) - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - fun state(state: String?) = apply { this.state = state } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) fun state(state: Optional) = state(state.orElse(null)) + fun state(state: JsonField) = apply { this.state = state } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1885,6 +2819,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2019,17 +2961,30 @@ constructor( class ReportingConfiguration @JsonCreator private constructor( - @JsonProperty("exempt") private val exempt: Boolean, + @JsonProperty("exempt") + @ExcludeMissing + private val exempt: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("exempt") fun exempt(): Boolean = exempt + fun exempt(): Boolean = exempt.getRequired("exempt") + + @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReportingConfiguration = apply { + if (!validated) { + exempt() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2039,7 +2994,7 @@ constructor( class Builder { - private var exempt: Boolean? = null + private var exempt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2048,7 +3003,9 @@ constructor( additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() } - fun exempt(exempt: Boolean) = apply { this.exempt = exempt } + fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) + + fun exempt(exempt: JsonField) = apply { this.exempt = exempt } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2098,33 +3055,73 @@ constructor( class ShippingAddress @JsonCreator private constructor( - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("line1") private val line1: String?, - @JsonProperty("line2") private val line2: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") + @ExcludeMissing + private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") + @ExcludeMissing + private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("city") fun city(): Optional = Optional.ofNullable(city) + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - @JsonProperty("country") fun country(): Optional = Optional.ofNullable(country) + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - @JsonProperty("line1") fun line1(): Optional = Optional.ofNullable(line1) + fun postalCode(): Optional = + Optional.ofNullable(postalCode.getNullable("postal_code")) - @JsonProperty("line2") fun line2(): Optional = Optional.ofNullable(line2) + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) + + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 @JsonProperty("postal_code") - fun postalCode(): Optional = Optional.ofNullable(postalCode) + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") fun state(): Optional = Optional.ofNullable(state) + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ShippingAddress = apply { + if (!validated) { + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2134,12 +3131,12 @@ constructor( class Builder { - private var city: String? = null - private var country: String? = null - private var line1: String? = null - private var line2: String? = null - private var postalCode: String? = null - private var state: String? = null + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2153,30 +3150,42 @@ constructor( additionalProperties = shippingAddress.additionalProperties.toMutableMap() } - fun city(city: String?) = apply { this.city = city } + fun city(city: String?) = city(JsonField.ofNullable(city)) fun city(city: Optional) = city(city.orElse(null)) - fun country(country: String?) = apply { this.country = country } + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) fun country(country: Optional) = country(country.orElse(null)) - fun line1(line1: String?) = apply { this.line1 = line1 } + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) fun line1(line1: Optional) = line1(line1.orElse(null)) - fun line2(line2: String?) = apply { this.line2 = line2 } + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) fun line2(line2: Optional) = line2(line2.orElse(null)) - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - fun state(state: String?) = apply { this.state = state } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) fun state(state: Optional) = state(state.orElse(null)) + fun state(state: JsonField) = apply { this.state = state } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2235,6 +3244,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newAvalaraTaxConfiguration(): Optional = Optional.ofNullable(newAvalaraTaxConfiguration) @@ -2263,6 +3274,17 @@ constructor( } } + fun validate(): TaxConfiguration = apply { + if (!validated) { + if (newAvalaraTaxConfiguration == null && newTaxJarConfiguration == null) { + throw OrbInvalidDataException("Unknown TaxConfiguration: $_json") + } + newAvalaraTaxConfiguration?.validate() + newTaxJarConfiguration?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2317,14 +3339,23 @@ constructor( when (taxProvider) { "avalara" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return TaxConfiguration(newAvalaraTaxConfiguration = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return TaxConfiguration( + newAvalaraTaxConfiguration = it, + _json = json + ) + } } "taxjar" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return TaxConfiguration(newTaxJarConfiguration = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return TaxConfiguration(newTaxJarConfiguration = it, _json = json) + } } } @@ -2354,24 +3385,53 @@ constructor( class NewAvalaraTaxConfiguration @JsonCreator private constructor( - @JsonProperty("tax_exempt") private val taxExempt: Boolean, - @JsonProperty("tax_provider") private val taxProvider: TaxProvider, - @JsonProperty("tax_exemption_code") private val taxExemptionCode: String?, + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), + @JsonProperty("tax_exemption_code") + @ExcludeMissing + private val taxExemptionCode: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("tax_exempt") fun taxExempt(): Boolean = taxExempt + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - @JsonProperty("tax_provider") fun taxProvider(): TaxProvider = taxProvider + fun taxExemptionCode(): Optional = + Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) + + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider @JsonProperty("tax_exemption_code") - fun taxExemptionCode(): Optional = Optional.ofNullable(taxExemptionCode) + @ExcludeMissing + fun _taxExemptionCode(): JsonField = taxExemptionCode @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAvalaraTaxConfiguration = apply { + if (!validated) { + taxExempt() + taxProvider() + taxExemptionCode() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2381,9 +3441,9 @@ constructor( class Builder { - private var taxExempt: Boolean? = null - private var taxProvider: TaxProvider? = null - private var taxExemptionCode: String? = null + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null + private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2395,17 +3455,26 @@ constructor( newAvalaraTaxConfiguration.additionalProperties.toMutableMap() } - fun taxExempt(taxExempt: Boolean) = apply { this.taxExempt = taxExempt } + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - fun taxProvider(taxProvider: TaxProvider) = apply { this.taxProvider = taxProvider } + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxExemptionCode(taxExemptionCode: String?) = apply { - this.taxExemptionCode = taxExemptionCode + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider } + fun taxExemptionCode(taxExemptionCode: String?) = + taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) + fun taxExemptionCode(taxExemptionCode: Optional) = taxExemptionCode(taxExemptionCode.orElse(null)) + fun taxExemptionCode(taxExemptionCode: JsonField) = apply { + this.taxExemptionCode = taxExemptionCode + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2510,20 +3579,42 @@ constructor( class NewTaxJarConfiguration @JsonCreator private constructor( - @JsonProperty("tax_exempt") private val taxExempt: Boolean, - @JsonProperty("tax_provider") private val taxProvider: TaxProvider, + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("tax_exempt") fun taxExempt(): Boolean = taxExempt + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt - @JsonProperty("tax_provider") fun taxProvider(): TaxProvider = taxProvider + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewTaxJarConfiguration = apply { + if (!validated) { + taxExempt() + taxProvider() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2533,8 +3624,8 @@ constructor( class Builder { - private var taxExempt: Boolean? = null - private var taxProvider: TaxProvider? = null + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2545,9 +3636,15 @@ constructor( newTaxJarConfiguration.additionalProperties.toMutableMap() } - fun taxExempt(taxExempt: Boolean) = apply { this.taxExempt = taxExempt } + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = apply { this.taxProvider = taxProvider } + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2759,23 +3856,44 @@ constructor( class TaxId @JsonCreator private constructor( - @JsonProperty("country") private val country: Country, - @JsonProperty("type") private val type: Type, - @JsonProperty("value") private val value: String, + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("country") fun country(): Country = country + fun country(): Country = country.getRequired("country") + + fun type(): Type = type.getRequired("type") + + fun value(): String = value.getRequired("value") - @JsonProperty("type") fun type(): Type = type + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("value") fun value(): String = value + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TaxId = apply { + if (!validated) { + country() + type() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2785,9 +3903,9 @@ constructor( class Builder { - private var country: Country? = null - private var type: Type? = null - private var value: String? = null + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2798,11 +3916,17 @@ constructor( additionalProperties = taxId.additionalProperties.toMutableMap() } - fun country(country: Country) = apply { this.country = country } + fun country(country: Country) = country(JsonField.of(country)) + + fun country(country: JsonField) = apply { this.country = country } + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } - fun type(type: Type) = apply { this.type = type } + fun value(value: String) = value(JsonField.of(value)) - fun value(value: String) = apply { this.value = value } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt index f33b0e2f..28ed28bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/CustomerUpdateParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,12 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint can be used to update the `payment_provider`, `payment_provider_id`, `name`, + * `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, + * `billing_address`, and `additional_emails` of an existing customer. Other fields on a customer + * are currently immutable. + */ class CustomerUpdateParams constructor( private val customerId: String, @@ -214,12 +221,187 @@ constructor( */ fun taxId(): Optional = body.taxId() - fun _additionalHeaders(): Headers = additionalHeaders + fun _accountingSyncConfiguration(): JsonField = + body._accountingSyncConfiguration() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun _additionalEmails(): JsonField> = body._additionalEmails() + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a saved + * payment method, if available. This parameter defaults to `True` when a payment provider is + * provided on customer creation. + */ + fun _autoCollection(): JsonField = body._autoCollection() + + fun _billingAddress(): JsonField = body._billingAddress() + + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun _currency(): JsonField = body._currency() + + /** A valid customer email, to be used for invoicing and notifications. */ + fun _email(): JsonField = body._email() + + fun _emailDelivery(): JsonField = body._emailDelivery() + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** The full name of the customer */ + fun _name(): JsonField = body._name() + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in test + * mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun _paymentProvider(): JsonField = body._paymentProvider() + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used for + * creating charges or invoices in the external system via Orb. + */ + fun _paymentProviderId(): JsonField = body._paymentProviderId() + + fun _reportingConfiguration(): JsonField = + body._reportingConfiguration() + + fun _shippingAddress(): JsonField = body._shippingAddress() + + fun _taxConfiguration(): JsonField = body._taxConfiguration() + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to the + * headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun _taxId(): JsonField = body._taxId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): CustomerUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -238,37 +420,256 @@ constructor( @JsonCreator internal constructor( @JsonProperty("accounting_sync_configuration") - private val accountingSyncConfiguration: AccountingSyncConfiguration?, - @JsonProperty("additional_emails") private val additionalEmails: List?, - @JsonProperty("auto_collection") private val autoCollection: Boolean?, - @JsonProperty("billing_address") private val billingAddress: BillingAddress?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("email") private val email: String?, - @JsonProperty("email_delivery") private val emailDelivery: Boolean?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("name") private val name: String?, - @JsonProperty("payment_provider") private val paymentProvider: PaymentProvider?, - @JsonProperty("payment_provider_id") private val paymentProviderId: String?, + @ExcludeMissing + private val accountingSyncConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("additional_emails") + @ExcludeMissing + private val additionalEmails: JsonField> = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("billing_address") + @ExcludeMissing + private val billingAddress: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("email") + @ExcludeMissing + private val email: JsonField = JsonMissing.of(), + @JsonProperty("email_delivery") + @ExcludeMissing + private val emailDelivery: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider") + @ExcludeMissing + private val paymentProvider: JsonField = JsonMissing.of(), + @JsonProperty("payment_provider_id") + @ExcludeMissing + private val paymentProviderId: JsonField = JsonMissing.of(), @JsonProperty("reporting_configuration") - private val reportingConfiguration: ReportingConfiguration?, - @JsonProperty("shipping_address") private val shippingAddress: ShippingAddress?, - @JsonProperty("tax_configuration") private val taxConfiguration: TaxConfiguration?, - @JsonProperty("tax_id") private val taxId: TaxId?, + @ExcludeMissing + private val reportingConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("shipping_address") + @ExcludeMissing + private val shippingAddress: JsonField = JsonMissing.of(), + @JsonProperty("tax_configuration") + @ExcludeMissing + private val taxConfiguration: JsonField = JsonMissing.of(), + @JsonProperty("tax_id") + @ExcludeMissing + private val taxId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun accountingSyncConfiguration(): Optional = + Optional.ofNullable( + accountingSyncConfiguration.getNullable("accounting_sync_configuration") + ) + + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(): Optional> = + Optional.ofNullable(additionalEmails.getNullable("additional_emails")) + + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun billingAddress(): Optional = + Optional.ofNullable(billingAddress.getNullable("billing_address")) + + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(): Optional = Optional.ofNullable(email.getNullable("email")) + + fun emailDelivery(): Optional = + Optional.ofNullable(emailDelivery.getNullable("email_delivery")) + + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The full name of the customer */ + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) + + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(): Optional = + Optional.ofNullable(paymentProvider.getNullable("payment_provider")) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(): Optional = + Optional.ofNullable(paymentProviderId.getNullable("payment_provider_id")) + + fun reportingConfiguration(): Optional = + Optional.ofNullable(reportingConfiguration.getNullable("reporting_configuration")) + + fun shippingAddress(): Optional = + Optional.ofNullable(shippingAddress.getNullable("shipping_address")) + + fun taxConfiguration(): Optional = + Optional.ofNullable(taxConfiguration.getNullable("tax_configuration")) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(): Optional = Optional.ofNullable(taxId.getNullable("tax_id")) + @JsonProperty("accounting_sync_configuration") - fun accountingSyncConfiguration(): Optional = - Optional.ofNullable(accountingSyncConfiguration) + @ExcludeMissing + fun _accountingSyncConfiguration(): JsonField = + accountingSyncConfiguration /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. */ @JsonProperty("additional_emails") - fun additionalEmails(): Optional> = Optional.ofNullable(additionalEmails) + @ExcludeMissing + fun _additionalEmails(): JsonField> = additionalEmails /** * Used to determine if invoices for this customer will automatically attempt to charge a @@ -276,39 +677,43 @@ constructor( * provider is provided on customer creation. */ @JsonProperty("auto_collection") - fun autoCollection(): Optional = Optional.ofNullable(autoCollection) + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_address") - fun billingAddress(): Optional = Optional.ofNullable(billingAddress) + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at * creation time, will be set at subscription creation time. */ - @JsonProperty("currency") fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** A valid customer email, to be used for invoicing and notifications. */ - @JsonProperty("email") fun email(): Optional = Optional.ofNullable(email) + @JsonProperty("email") @ExcludeMissing fun _email(): JsonField = email @JsonProperty("email_delivery") - fun emailDelivery(): Optional = Optional.ofNullable(emailDelivery) + @ExcludeMissing + fun _emailDelivery(): JsonField = emailDelivery /** * The external customer ID. This can only be set if empty and the customer has no past or * current subscriptions. */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The full name of the customer */ - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * This is used for creating charges or invoices in an external system via Orb. When not in @@ -318,24 +723,28 @@ constructor( * `netsuite`), any product mappings must first be configured with the Orb team. */ @JsonProperty("payment_provider") - fun paymentProvider(): Optional = Optional.ofNullable(paymentProvider) + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider /** * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ @JsonProperty("payment_provider_id") - fun paymentProviderId(): Optional = Optional.ofNullable(paymentProviderId) + @ExcludeMissing + fun _paymentProviderId(): JsonField = paymentProviderId @JsonProperty("reporting_configuration") - fun reportingConfiguration(): Optional = - Optional.ofNullable(reportingConfiguration) + @ExcludeMissing + fun _reportingConfiguration(): JsonField = reportingConfiguration @JsonProperty("shipping_address") - fun shippingAddress(): Optional = Optional.ofNullable(shippingAddress) + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress @JsonProperty("tax_configuration") - fun taxConfiguration(): Optional = Optional.ofNullable(taxConfiguration) + @ExcludeMissing + fun _taxConfiguration(): JsonField = taxConfiguration /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -443,12 +852,36 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("tax_id") fun taxId(): Optional = Optional.ofNullable(taxId) + @JsonProperty("tax_id") @ExcludeMissing fun _taxId(): JsonField = taxId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): CustomerUpdateBody = apply { + if (!validated) { + accountingSyncConfiguration().map { it.validate() } + additionalEmails() + autoCollection() + billingAddress().map { it.validate() } + currency() + email() + emailDelivery() + externalCustomerId() + metadata().map { it.validate() } + name() + paymentProvider() + paymentProviderId() + reportingConfiguration().map { it.validate() } + shippingAddress().map { it.validate() } + taxConfiguration() + taxId().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -458,28 +891,29 @@ constructor( class Builder { - private var accountingSyncConfiguration: AccountingSyncConfiguration? = null - private var additionalEmails: MutableList? = null - private var autoCollection: Boolean? = null - private var billingAddress: BillingAddress? = null - private var currency: String? = null - private var email: String? = null - private var emailDelivery: Boolean? = null - private var externalCustomerId: String? = null - private var metadata: Metadata? = null - private var name: String? = null - private var paymentProvider: PaymentProvider? = null - private var paymentProviderId: String? = null - private var reportingConfiguration: ReportingConfiguration? = null - private var shippingAddress: ShippingAddress? = null - private var taxConfiguration: TaxConfiguration? = null - private var taxId: TaxId? = null + private var accountingSyncConfiguration: JsonField = + JsonMissing.of() + private var additionalEmails: JsonField>? = null + private var autoCollection: JsonField = JsonMissing.of() + private var billingAddress: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var email: JsonField = JsonMissing.of() + private var emailDelivery: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var name: JsonField = JsonMissing.of() + private var paymentProvider: JsonField = JsonMissing.of() + private var paymentProviderId: JsonField = JsonMissing.of() + private var reportingConfiguration: JsonField = JsonMissing.of() + private var shippingAddress: JsonField = JsonMissing.of() + private var taxConfiguration: JsonField = JsonMissing.of() + private var taxId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(customerUpdateBody: CustomerUpdateBody) = apply { accountingSyncConfiguration = customerUpdateBody.accountingSyncConfiguration - additionalEmails = customerUpdateBody.additionalEmails?.toMutableList() + additionalEmails = customerUpdateBody.additionalEmails.map { it.toMutableList() } autoCollection = customerUpdateBody.autoCollection billingAddress = customerUpdateBody.billingAddress currency = customerUpdateBody.currency @@ -499,19 +933,22 @@ constructor( fun accountingSyncConfiguration( accountingSyncConfiguration: AccountingSyncConfiguration? - ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + ) = accountingSyncConfiguration(JsonField.ofNullable(accountingSyncConfiguration)) fun accountingSyncConfiguration( accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { this.accountingSyncConfiguration = accountingSyncConfiguration } + /** * Additional email addresses for this customer. If populated, these email addresses * will be CC'd for customer communications. */ - fun additionalEmails(additionalEmails: List?) = apply { - this.additionalEmails = additionalEmails?.toMutableList() - } + fun additionalEmails(additionalEmails: List?) = + additionalEmails(JsonField.ofNullable(additionalEmails)) /** * Additional email addresses for this customer. If populated, these email addresses @@ -520,13 +957,29 @@ constructor( fun additionalEmails(additionalEmails: Optional>) = additionalEmails(additionalEmails.orElse(null)) + /** + * Additional email addresses for this customer. If populated, these email addresses + * will be CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + this.additionalEmails = additionalEmails.map { it.toMutableList() } + } + /** * Additional email addresses for this customer. If populated, these email addresses * will be CC'd for customer communications. */ fun addAdditionalEmail(additionalEmail: String) = apply { additionalEmails = - (additionalEmails ?: mutableListOf()).apply { add(additionalEmail) } + (additionalEmails ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(additionalEmail) + } } /** @@ -534,9 +987,8 @@ constructor( * a saved payment method, if available. This parameter defaults to `True` when a * payment provider is provided on customer creation. */ - fun autoCollection(autoCollection: Boolean?) = apply { - this.autoCollection = autoCollection - } + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) /** * Used to determine if invoices for this customer will automatically attempt to charge @@ -554,18 +1006,30 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) - fun billingAddress(billingAddress: BillingAddress?) = apply { - this.billingAddress = billingAddress + /** + * Used to determine if invoices for this customer will automatically attempt to charge + * a saved payment method, if available. This parameter defaults to `True` when a + * payment provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection } + fun billingAddress(billingAddress: BillingAddress?) = + billingAddress(JsonField.ofNullable(billingAddress)) + fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) + fun billingAddress(billingAddress: JsonField) = apply { + this.billingAddress = billingAddress + } + /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set * at creation time, will be set at subscription creation time. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set @@ -573,15 +1037,23 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set + * at creation time, will be set at subscription creation time. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** A valid customer email, to be used for invoicing and notifications. */ - fun email(email: String?) = apply { this.email = email } + fun email(email: String?) = email(JsonField.ofNullable(email)) /** A valid customer email, to be used for invoicing and notifications. */ fun email(email: Optional) = email(email.orElse(null)) - fun emailDelivery(emailDelivery: Boolean?) = apply { - this.emailDelivery = emailDelivery - } + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: JsonField) = apply { this.email = email } + + fun emailDelivery(emailDelivery: Boolean?) = + emailDelivery(JsonField.ofNullable(emailDelivery)) fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) @@ -589,13 +1061,16 @@ constructor( fun emailDelivery(emailDelivery: Optional) = emailDelivery(emailDelivery.orElse(null) as Boolean?) + fun emailDelivery(emailDelivery: JsonField) = apply { + this.emailDelivery = emailDelivery + } + /** * The external customer ID. This can only be set if empty and the customer has no past * or current subscriptions. */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * The external customer ID. This can only be set if empty and the customer has no past @@ -604,12 +1079,20 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * The external customer ID. This can only be set if empty and the customer has no past + * or current subscriptions. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -618,12 +1101,22 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** The full name of the customer */ - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) /** The full name of the customer */ fun name(name: Optional) = name(name.orElse(null)) + /** The full name of the customer */ + fun name(name: JsonField) = apply { this.name = name } + /** * This is used for creating charges or invoices in an external system via Orb. When not * in test mode: @@ -632,9 +1125,8 @@ constructor( * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb * team. */ - fun paymentProvider(paymentProvider: PaymentProvider?) = apply { - this.paymentProvider = paymentProvider - } + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) /** * This is used for creating charges or invoices in an external system via Orb. When not @@ -647,54 +1139,188 @@ constructor( fun paymentProvider(paymentProvider: Optional) = paymentProvider(paymentProvider.orElse(null)) + /** + * This is used for creating charges or invoices in an external system via Orb. When not + * in test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, + * `bill.com`, `netsuite`), any product mappings must first be configured with the Orb + * team. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + this.paymentProvider = paymentProvider + } + /** * The ID of this customer in an external payments solution, such as Stripe. This is * used for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: String?) = apply { - this.paymentProviderId = paymentProviderId - } + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is + * used for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) /** * The ID of this customer in an external payments solution, such as Stripe. This is * used for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - this.reportingConfiguration = reportingConfiguration - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - this.shippingAddress = shippingAddress - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - this.taxConfiguration = taxConfiguration - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration( - newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration - ) = apply { - this.taxConfiguration = - TaxConfiguration.ofNewAvalaraTaxConfiguration(newAvalaraTaxConfiguration) - } - - fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = - apply { - this.taxConfiguration = - TaxConfiguration.ofNewTaxJarConfiguration(newTaxJarConfiguration) - } + fun paymentProviderId(paymentProviderId: JsonField) = apply { + this.paymentProviderId = paymentProviderId + } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = + reportingConfiguration(JsonField.ofNullable(reportingConfiguration)) + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + this.reportingConfiguration = reportingConfiguration + } + + fun shippingAddress(shippingAddress: ShippingAddress?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + this.shippingAddress = shippingAddress + } + + fun taxConfiguration(taxConfiguration: TaxConfiguration?) = + taxConfiguration(JsonField.ofNullable(taxConfiguration)) + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + this.taxConfiguration = taxConfiguration + } + + fun taxConfiguration( + newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration + ) = + taxConfiguration( + TaxConfiguration.ofNewAvalaraTaxConfiguration(newAvalaraTaxConfiguration) + ) + + fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = + taxConfiguration(TaxConfiguration.ofNewTaxJarConfiguration(newTaxJarConfiguration)) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added + * to the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: TaxId?) = taxId(JsonField.ofNullable(taxId)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -802,7 +1428,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { this.taxId = taxId } + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added @@ -910,7 +1536,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: JsonField) = apply { this.taxId = taxId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -934,7 +1560,7 @@ constructor( fun build(): CustomerUpdateBody = CustomerUpdateBody( accountingSyncConfiguration, - additionalEmails?.toImmutable(), + (additionalEmails ?: JsonMissing.of()).map { it.toImmutable() }, autoCollection, billingAddress, currency, @@ -1005,6 +1631,10 @@ constructor( accountingSyncConfiguration: Optional ) = accountingSyncConfiguration(accountingSyncConfiguration.orElse(null)) + fun accountingSyncConfiguration( + accountingSyncConfiguration: JsonField + ) = apply { body.accountingSyncConfiguration(accountingSyncConfiguration) } + /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. @@ -1020,6 +1650,14 @@ constructor( fun additionalEmails(additionalEmails: Optional>) = additionalEmails(additionalEmails.orElse(null)) + /** + * Additional email addresses for this customer. If populated, these email addresses will be + * CC'd for customer communications. + */ + fun additionalEmails(additionalEmails: JsonField>) = apply { + body.additionalEmails(additionalEmails) + } + /** * Additional email addresses for this customer. If populated, these email addresses will be * CC'd for customer communications. @@ -1051,6 +1689,15 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Used to determine if invoices for this customer will automatically attempt to charge a + * saved payment method, if available. This parameter defaults to `True` when a payment + * provider is provided on customer creation. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + fun billingAddress(billingAddress: BillingAddress?) = apply { body.billingAddress(billingAddress) } @@ -1058,6 +1705,10 @@ constructor( fun billingAddress(billingAddress: Optional) = billingAddress(billingAddress.orElse(null)) + fun billingAddress(billingAddress: JsonField) = apply { + body.billingAddress(billingAddress) + } + /** * An ISO 4217 currency string used for the customer's invoices and balance. If not set at * creation time, will be set at subscription creation time. @@ -1070,12 +1721,21 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string used for the customer's invoices and balance. If not set at + * creation time, will be set at subscription creation time. + */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** A valid customer email, to be used for invoicing and notifications. */ fun email(email: String?) = apply { body.email(email) } /** A valid customer email, to be used for invoicing and notifications. */ fun email(email: Optional) = email(email.orElse(null)) + /** A valid customer email, to be used for invoicing and notifications. */ + fun email(email: JsonField) = apply { body.email(email) } + fun emailDelivery(emailDelivery: Boolean?) = apply { body.emailDelivery(emailDelivery) } fun emailDelivery(emailDelivery: Boolean) = emailDelivery(emailDelivery as Boolean?) @@ -1084,6 +1744,10 @@ constructor( fun emailDelivery(emailDelivery: Optional) = emailDelivery(emailDelivery.orElse(null) as Boolean?) + fun emailDelivery(emailDelivery: JsonField) = apply { + body.emailDelivery(emailDelivery) + } + /** * The external customer ID. This can only be set if empty and the customer has no past or * current subscriptions. @@ -1099,6 +1763,14 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * The external customer ID. This can only be set if empty and the customer has no past or + * current subscriptions. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -1113,12 +1785,22 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** The full name of the customer */ fun name(name: String?) = apply { body.name(name) } /** The full name of the customer */ fun name(name: Optional) = name(name.orElse(null)) + /** The full name of the customer */ + fun name(name: JsonField) = apply { body.name(name) } + /** * This is used for creating charges or invoices in an external system via Orb. When not in * test mode: @@ -1140,6 +1822,17 @@ constructor( fun paymentProvider(paymentProvider: Optional) = paymentProvider(paymentProvider.orElse(null)) + /** + * This is used for creating charges or invoices in an external system via Orb. When not in + * test mode: + * - the connection must first be configured in the Orb webapp. + * - if the provider is an invoicing provider (`stripe_invoice`, `quickbooks`, `bill.com`, + * `netsuite`), any product mappings must first be configured with the Orb team. + */ + fun paymentProvider(paymentProvider: JsonField) = apply { + body.paymentProvider(paymentProvider) + } + /** * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. @@ -1152,38 +1845,167 @@ constructor( * The ID of this customer in an external payments solution, such as Stripe. This is used * for creating charges or invoices in the external system via Orb. */ - fun paymentProviderId(paymentProviderId: Optional) = - paymentProviderId(paymentProviderId.orElse(null)) - - fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { - body.reportingConfiguration(reportingConfiguration) - } - - fun reportingConfiguration(reportingConfiguration: Optional) = - reportingConfiguration(reportingConfiguration.orElse(null)) - - fun shippingAddress(shippingAddress: ShippingAddress?) = apply { - body.shippingAddress(shippingAddress) - } - - fun shippingAddress(shippingAddress: Optional) = - shippingAddress(shippingAddress.orElse(null)) - - fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { - body.taxConfiguration(taxConfiguration) - } - - fun taxConfiguration(taxConfiguration: Optional) = - taxConfiguration(taxConfiguration.orElse(null)) - - fun taxConfiguration( - newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration - ) = apply { body.taxConfiguration(newAvalaraTaxConfiguration) } - - fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = - apply { - body.taxConfiguration(newTaxJarConfiguration) - } + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) + + /** + * The ID of this customer in an external payments solution, such as Stripe. This is used + * for creating charges or invoices in the external system via Orb. + */ + fun paymentProviderId(paymentProviderId: JsonField) = apply { + body.paymentProviderId(paymentProviderId) + } + + fun reportingConfiguration(reportingConfiguration: ReportingConfiguration?) = apply { + body.reportingConfiguration(reportingConfiguration) + } + + fun reportingConfiguration(reportingConfiguration: Optional) = + reportingConfiguration(reportingConfiguration.orElse(null)) + + fun reportingConfiguration(reportingConfiguration: JsonField) = + apply { + body.reportingConfiguration(reportingConfiguration) + } + + fun shippingAddress(shippingAddress: ShippingAddress?) = apply { + body.shippingAddress(shippingAddress) + } + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) + + fun shippingAddress(shippingAddress: JsonField) = apply { + body.shippingAddress(shippingAddress) + } + + fun taxConfiguration(taxConfiguration: TaxConfiguration?) = apply { + body.taxConfiguration(taxConfiguration) + } + + fun taxConfiguration(taxConfiguration: Optional) = + taxConfiguration(taxConfiguration.orElse(null)) + + fun taxConfiguration(taxConfiguration: JsonField) = apply { + body.taxConfiguration(taxConfiguration) + } + + fun taxConfiguration( + newAvalaraTaxConfiguration: TaxConfiguration.NewAvalaraTaxConfiguration + ) = apply { body.taxConfiguration(newAvalaraTaxConfiguration) } + + fun taxConfiguration(newTaxJarConfiguration: TaxConfiguration.NewTaxJarConfiguration) = + apply { + body.taxConfiguration(newTaxJarConfiguration) + } + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1291,7 +2113,7 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: TaxId?) = apply { body.taxId(taxId) } + fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1399,7 +2221,26 @@ constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun taxId(taxId: Optional) = taxId(taxId.orElse(null)) + fun taxId(taxId: JsonField) = apply { body.taxId(taxId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -1499,25 +2340,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): CustomerUpdateParams = CustomerUpdateParams( checkNotNull(customerId) { "`customerId` is required but was not set" }, @@ -1532,22 +2354,40 @@ constructor( @JsonCreator private constructor( @JsonProperty("accounting_providers") - private val accountingProviders: List?, - @JsonProperty("excluded") private val excluded: Boolean?, + @ExcludeMissing + private val accountingProviders: JsonField> = JsonMissing.of(), + @JsonProperty("excluded") + @ExcludeMissing + private val excluded: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("accounting_providers") fun accountingProviders(): Optional> = - Optional.ofNullable(accountingProviders) + Optional.ofNullable(accountingProviders.getNullable("accounting_providers")) + + fun excluded(): Optional = Optional.ofNullable(excluded.getNullable("excluded")) + + @JsonProperty("accounting_providers") + @ExcludeMissing + fun _accountingProviders(): JsonField> = accountingProviders - @JsonProperty("excluded") fun excluded(): Optional = Optional.ofNullable(excluded) + @JsonProperty("excluded") @ExcludeMissing fun _excluded(): JsonField = excluded @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountingSyncConfiguration = apply { + if (!validated) { + accountingProviders().map { it.forEach { it.validate() } } + excluded() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1557,38 +2397,52 @@ constructor( class Builder { - private var accountingProviders: MutableList? = null - private var excluded: Boolean? = null + private var accountingProviders: JsonField>? = null + private var excluded: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(accountingSyncConfiguration: AccountingSyncConfiguration) = apply { accountingProviders = - accountingSyncConfiguration.accountingProviders?.toMutableList() + accountingSyncConfiguration.accountingProviders.map { it.toMutableList() } excluded = accountingSyncConfiguration.excluded additionalProperties = accountingSyncConfiguration.additionalProperties.toMutableMap() } - fun accountingProviders(accountingProviders: List?) = apply { - this.accountingProviders = accountingProviders?.toMutableList() - } + fun accountingProviders(accountingProviders: List?) = + accountingProviders(JsonField.ofNullable(accountingProviders)) fun accountingProviders(accountingProviders: Optional>) = accountingProviders(accountingProviders.orElse(null)) + fun accountingProviders(accountingProviders: JsonField>) = + apply { + this.accountingProviders = accountingProviders.map { it.toMutableList() } + } + fun addAccountingProvider(accountingProvider: AccountingProvider) = apply { accountingProviders = - (accountingProviders ?: mutableListOf()).apply { add(accountingProvider) } + (accountingProviders ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(accountingProvider) + } } - fun excluded(excluded: Boolean?) = apply { this.excluded = excluded } + fun excluded(excluded: Boolean?) = excluded(JsonField.ofNullable(excluded)) fun excluded(excluded: Boolean) = excluded(excluded as Boolean?) @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun excluded(excluded: Optional) = excluded(excluded.orElse(null) as Boolean?) + fun excluded(excluded: JsonField) = apply { this.excluded = excluded } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1610,7 +2464,7 @@ constructor( fun build(): AccountingSyncConfiguration = AccountingSyncConfiguration( - accountingProviders?.toImmutable(), + (accountingProviders ?: JsonMissing.of()).map { it.toImmutable() }, excluded, additionalProperties.toImmutable(), ) @@ -1620,21 +2474,43 @@ constructor( class AccountingProvider @JsonCreator private constructor( - @JsonProperty("external_provider_id") private val externalProviderId: String, - @JsonProperty("provider_type") private val providerType: String, + @JsonProperty("external_provider_id") + @ExcludeMissing + private val externalProviderId: JsonField = JsonMissing.of(), + @JsonProperty("provider_type") + @ExcludeMissing + private val providerType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun externalProviderId(): String = + externalProviderId.getRequired("external_provider_id") + + fun providerType(): String = providerType.getRequired("provider_type") + @JsonProperty("external_provider_id") - fun externalProviderId(): String = externalProviderId + @ExcludeMissing + fun _externalProviderId(): JsonField = externalProviderId - @JsonProperty("provider_type") fun providerType(): String = providerType + @JsonProperty("provider_type") + @ExcludeMissing + fun _providerType(): JsonField = providerType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AccountingProvider = apply { + if (!validated) { + externalProviderId() + providerType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1644,8 +2520,8 @@ constructor( class Builder { - private var externalProviderId: String? = null - private var providerType: String? = null + private var externalProviderId: JsonField? = null + private var providerType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1655,11 +2531,18 @@ constructor( additionalProperties = accountingProvider.additionalProperties.toMutableMap() } - fun externalProviderId(externalProviderId: String) = apply { + fun externalProviderId(externalProviderId: String) = + externalProviderId(JsonField.of(externalProviderId)) + + fun externalProviderId(externalProviderId: JsonField) = apply { this.externalProviderId = externalProviderId } - fun providerType(providerType: String) = apply { this.providerType = providerType } + fun providerType(providerType: String) = providerType(JsonField.of(providerType)) + + fun providerType(providerType: JsonField) = apply { + this.providerType = providerType + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1733,33 +2616,73 @@ constructor( class BillingAddress @JsonCreator private constructor( - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("line1") private val line1: String?, - @JsonProperty("line2") private val line2: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") + @ExcludeMissing + private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") + @ExcludeMissing + private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("city") fun city(): Optional = Optional.ofNullable(city) + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) + + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) + + fun postalCode(): Optional = + Optional.ofNullable(postalCode.getNullable("postal_code")) - @JsonProperty("country") fun country(): Optional = Optional.ofNullable(country) + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("line1") fun line1(): Optional = Optional.ofNullable(line1) + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("line2") fun line2(): Optional = Optional.ofNullable(line2) + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 @JsonProperty("postal_code") - fun postalCode(): Optional = Optional.ofNullable(postalCode) + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") fun state(): Optional = Optional.ofNullable(state) + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingAddress = apply { + if (!validated) { + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1769,12 +2692,12 @@ constructor( class Builder { - private var city: String? = null - private var country: String? = null - private var line1: String? = null - private var line2: String? = null - private var postalCode: String? = null - private var state: String? = null + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1788,30 +2711,42 @@ constructor( additionalProperties = billingAddress.additionalProperties.toMutableMap() } - fun city(city: String?) = apply { this.city = city } + fun city(city: String?) = city(JsonField.ofNullable(city)) fun city(city: Optional) = city(city.orElse(null)) - fun country(country: String?) = apply { this.country = country } + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) fun country(country: Optional) = country(country.orElse(null)) - fun line1(line1: String?) = apply { this.line1 = line1 } + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) fun line1(line1: Optional) = line1(line1.orElse(null)) - fun line2(line2: String?) = apply { this.line2 = line2 } + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) fun line2(line2: Optional) = line2(line2.orElse(null)) - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - fun state(state: String?) = apply { this.state = state } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) fun state(state: Optional) = state(state.orElse(null)) + fun state(state: JsonField) = apply { this.state = state } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1878,6 +2813,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2012,17 +2955,30 @@ constructor( class ReportingConfiguration @JsonCreator private constructor( - @JsonProperty("exempt") private val exempt: Boolean, + @JsonProperty("exempt") + @ExcludeMissing + private val exempt: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("exempt") fun exempt(): Boolean = exempt + fun exempt(): Boolean = exempt.getRequired("exempt") + + @JsonProperty("exempt") @ExcludeMissing fun _exempt(): JsonField = exempt @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReportingConfiguration = apply { + if (!validated) { + exempt() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2032,7 +2988,7 @@ constructor( class Builder { - private var exempt: Boolean? = null + private var exempt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2041,7 +2997,9 @@ constructor( additionalProperties = reportingConfiguration.additionalProperties.toMutableMap() } - fun exempt(exempt: Boolean) = apply { this.exempt = exempt } + fun exempt(exempt: Boolean) = exempt(JsonField.of(exempt)) + + fun exempt(exempt: JsonField) = apply { this.exempt = exempt } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2091,33 +3049,73 @@ constructor( class ShippingAddress @JsonCreator private constructor( - @JsonProperty("city") private val city: String?, - @JsonProperty("country") private val country: String?, - @JsonProperty("line1") private val line1: String?, - @JsonProperty("line2") private val line2: String?, - @JsonProperty("postal_code") private val postalCode: String?, - @JsonProperty("state") private val state: String?, + @JsonProperty("city") + @ExcludeMissing + private val city: JsonField = JsonMissing.of(), + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("line1") + @ExcludeMissing + private val line1: JsonField = JsonMissing.of(), + @JsonProperty("line2") + @ExcludeMissing + private val line2: JsonField = JsonMissing.of(), + @JsonProperty("postal_code") + @ExcludeMissing + private val postalCode: JsonField = JsonMissing.of(), + @JsonProperty("state") + @ExcludeMissing + private val state: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("city") fun city(): Optional = Optional.ofNullable(city) + fun city(): Optional = Optional.ofNullable(city.getNullable("city")) + + fun country(): Optional = Optional.ofNullable(country.getNullable("country")) + + fun line1(): Optional = Optional.ofNullable(line1.getNullable("line1")) - @JsonProperty("country") fun country(): Optional = Optional.ofNullable(country) + fun line2(): Optional = Optional.ofNullable(line2.getNullable("line2")) - @JsonProperty("line1") fun line1(): Optional = Optional.ofNullable(line1) + fun postalCode(): Optional = + Optional.ofNullable(postalCode.getNullable("postal_code")) - @JsonProperty("line2") fun line2(): Optional = Optional.ofNullable(line2) + fun state(): Optional = Optional.ofNullable(state.getNullable("state")) + + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city + + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country + + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 + + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 @JsonProperty("postal_code") - fun postalCode(): Optional = Optional.ofNullable(postalCode) + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") fun state(): Optional = Optional.ofNullable(state) + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ShippingAddress = apply { + if (!validated) { + city() + country() + line1() + line2() + postalCode() + state() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2127,12 +3125,12 @@ constructor( class Builder { - private var city: String? = null - private var country: String? = null - private var line1: String? = null - private var line2: String? = null - private var postalCode: String? = null - private var state: String? = null + private var city: JsonField = JsonMissing.of() + private var country: JsonField = JsonMissing.of() + private var line1: JsonField = JsonMissing.of() + private var line2: JsonField = JsonMissing.of() + private var postalCode: JsonField = JsonMissing.of() + private var state: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2146,30 +3144,42 @@ constructor( additionalProperties = shippingAddress.additionalProperties.toMutableMap() } - fun city(city: String?) = apply { this.city = city } + fun city(city: String?) = city(JsonField.ofNullable(city)) fun city(city: Optional) = city(city.orElse(null)) - fun country(country: String?) = apply { this.country = country } + fun city(city: JsonField) = apply { this.city = city } + + fun country(country: String?) = country(JsonField.ofNullable(country)) fun country(country: Optional) = country(country.orElse(null)) - fun line1(line1: String?) = apply { this.line1 = line1 } + fun country(country: JsonField) = apply { this.country = country } + + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) fun line1(line1: Optional) = line1(line1.orElse(null)) - fun line2(line2: String?) = apply { this.line2 = line2 } + fun line1(line1: JsonField) = apply { this.line1 = line1 } + + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) fun line2(line2: Optional) = line2(line2.orElse(null)) - fun postalCode(postalCode: String?) = apply { this.postalCode = postalCode } + fun line2(line2: JsonField) = apply { this.line2 = line2 } + + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) - fun state(state: String?) = apply { this.state = state } + fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } + + fun state(state: String?) = state(JsonField.ofNullable(state)) fun state(state: Optional) = state(state.orElse(null)) + fun state(state: JsonField) = apply { this.state = state } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2228,6 +3238,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newAvalaraTaxConfiguration(): Optional = Optional.ofNullable(newAvalaraTaxConfiguration) @@ -2256,6 +3268,17 @@ constructor( } } + fun validate(): TaxConfiguration = apply { + if (!validated) { + if (newAvalaraTaxConfiguration == null && newTaxJarConfiguration == null) { + throw OrbInvalidDataException("Unknown TaxConfiguration: $_json") + } + newAvalaraTaxConfiguration?.validate() + newTaxJarConfiguration?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2310,14 +3333,23 @@ constructor( when (taxProvider) { "avalara" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return TaxConfiguration(newAvalaraTaxConfiguration = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return TaxConfiguration( + newAvalaraTaxConfiguration = it, + _json = json + ) + } } "taxjar" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return TaxConfiguration(newTaxJarConfiguration = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return TaxConfiguration(newTaxJarConfiguration = it, _json = json) + } } } @@ -2347,24 +3379,53 @@ constructor( class NewAvalaraTaxConfiguration @JsonCreator private constructor( - @JsonProperty("tax_exempt") private val taxExempt: Boolean, - @JsonProperty("tax_provider") private val taxProvider: TaxProvider, - @JsonProperty("tax_exemption_code") private val taxExemptionCode: String?, + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), + @JsonProperty("tax_exemption_code") + @ExcludeMissing + private val taxExemptionCode: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("tax_exempt") fun taxExempt(): Boolean = taxExempt + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") - @JsonProperty("tax_provider") fun taxProvider(): TaxProvider = taxProvider + fun taxExemptionCode(): Optional = + Optional.ofNullable(taxExemptionCode.getNullable("tax_exemption_code")) + + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt + + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider @JsonProperty("tax_exemption_code") - fun taxExemptionCode(): Optional = Optional.ofNullable(taxExemptionCode) + @ExcludeMissing + fun _taxExemptionCode(): JsonField = taxExemptionCode @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAvalaraTaxConfiguration = apply { + if (!validated) { + taxExempt() + taxProvider() + taxExemptionCode() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2374,9 +3435,9 @@ constructor( class Builder { - private var taxExempt: Boolean? = null - private var taxProvider: TaxProvider? = null - private var taxExemptionCode: String? = null + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null + private var taxExemptionCode: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2388,17 +3449,26 @@ constructor( newAvalaraTaxConfiguration.additionalProperties.toMutableMap() } - fun taxExempt(taxExempt: Boolean) = apply { this.taxExempt = taxExempt } + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) - fun taxProvider(taxProvider: TaxProvider) = apply { this.taxProvider = taxProvider } + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxExemptionCode(taxExemptionCode: String?) = apply { - this.taxExemptionCode = taxExemptionCode + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider } + fun taxExemptionCode(taxExemptionCode: String?) = + taxExemptionCode(JsonField.ofNullable(taxExemptionCode)) + fun taxExemptionCode(taxExemptionCode: Optional) = taxExemptionCode(taxExemptionCode.orElse(null)) + fun taxExemptionCode(taxExemptionCode: JsonField) = apply { + this.taxExemptionCode = taxExemptionCode + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2503,20 +3573,42 @@ constructor( class NewTaxJarConfiguration @JsonCreator private constructor( - @JsonProperty("tax_exempt") private val taxExempt: Boolean, - @JsonProperty("tax_provider") private val taxProvider: TaxProvider, + @JsonProperty("tax_exempt") + @ExcludeMissing + private val taxExempt: JsonField = JsonMissing.of(), + @JsonProperty("tax_provider") + @ExcludeMissing + private val taxProvider: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("tax_exempt") fun taxExempt(): Boolean = taxExempt + fun taxExempt(): Boolean = taxExempt.getRequired("tax_exempt") + + fun taxProvider(): TaxProvider = taxProvider.getRequired("tax_provider") + + @JsonProperty("tax_exempt") + @ExcludeMissing + fun _taxExempt(): JsonField = taxExempt - @JsonProperty("tax_provider") fun taxProvider(): TaxProvider = taxProvider + @JsonProperty("tax_provider") + @ExcludeMissing + fun _taxProvider(): JsonField = taxProvider @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewTaxJarConfiguration = apply { + if (!validated) { + taxExempt() + taxProvider() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2526,8 +3618,8 @@ constructor( class Builder { - private var taxExempt: Boolean? = null - private var taxProvider: TaxProvider? = null + private var taxExempt: JsonField? = null + private var taxProvider: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2538,9 +3630,15 @@ constructor( newTaxJarConfiguration.additionalProperties.toMutableMap() } - fun taxExempt(taxExempt: Boolean) = apply { this.taxExempt = taxExempt } + fun taxExempt(taxExempt: Boolean) = taxExempt(JsonField.of(taxExempt)) + + fun taxExempt(taxExempt: JsonField) = apply { this.taxExempt = taxExempt } - fun taxProvider(taxProvider: TaxProvider) = apply { this.taxProvider = taxProvider } + fun taxProvider(taxProvider: TaxProvider) = taxProvider(JsonField.of(taxProvider)) + + fun taxProvider(taxProvider: JsonField) = apply { + this.taxProvider = taxProvider + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2752,23 +3850,44 @@ constructor( class TaxId @JsonCreator private constructor( - @JsonProperty("country") private val country: Country, - @JsonProperty("type") private val type: Type, - @JsonProperty("value") private val value: String, + @JsonProperty("country") + @ExcludeMissing + private val country: JsonField = JsonMissing.of(), + @JsonProperty("type") @ExcludeMissing private val type: JsonField = JsonMissing.of(), + @JsonProperty("value") + @ExcludeMissing + private val value: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("country") fun country(): Country = country + fun country(): Country = country.getRequired("country") + + fun type(): Type = type.getRequired("type") + + fun value(): String = value.getRequired("value") - @JsonProperty("type") fun type(): Type = type + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("value") fun value(): String = value + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type + + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TaxId = apply { + if (!validated) { + country() + type() + value() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2778,9 +3897,9 @@ constructor( class Builder { - private var country: Country? = null - private var type: Type? = null - private var value: String? = null + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2791,11 +3910,17 @@ constructor( additionalProperties = taxId.additionalProperties.toMutableMap() } - fun country(country: Country) = apply { this.country = country } + fun country(country: Country) = country(JsonField.of(country)) + + fun country(country: JsonField) = apply { this.country = country } + + fun type(type: Type) = type(JsonField.of(type)) + + fun type(type: JsonField) = apply { this.type = type } - fun type(type: Type) = apply { this.type = type } + fun value(value: String) = value(JsonField.of(value)) - fun value(value: String) = apply { this.value = value } + fun value(value: JsonField) = apply { this.value = value } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt index 644d2fbc..4d8d57d0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroup.kt @@ -68,31 +68,35 @@ private constructor( /** The name of the dimensional price group */ fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * The billable metric associated with this dimensional price group. All prices associated with * this dimensional price group will be computed using this billable metric. */ - @JsonProperty("billable_metric_id") @ExcludeMissing fun _billableMetricId() = billableMetricId + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** The dimensions that this dimensional price group is defined over */ - @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** An alias for the dimensional price group */ @JsonProperty("external_dimensional_price_group_id") @ExcludeMissing - fun _externalDimensionalPriceGroupId() = externalDimensionalPriceGroupId + fun _externalDimensionalPriceGroupId(): JsonField = externalDimensionalPriceGroupId /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The name of the dimensional price group */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -121,19 +125,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetricId: JsonField = JsonMissing.of() - private var dimensions: JsonField> = JsonMissing.of() - private var externalDimensionalPriceGroupId: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetricId: JsonField? = null + private var dimensions: JsonField>? = null + private var externalDimensionalPriceGroupId: JsonField? = null + private var metadata: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(dimensionalPriceGroup: DimensionalPriceGroup) = apply { id = dimensionalPriceGroup.id billableMetricId = dimensionalPriceGroup.billableMetricId - dimensions = dimensionalPriceGroup.dimensions + dimensions = dimensionalPriceGroup.dimensions.map { it.toMutableList() } externalDimensionalPriceGroupId = dimensionalPriceGroup.externalDimensionalPriceGroupId metadata = dimensionalPriceGroup.metadata name = dimensionalPriceGroup.name @@ -163,11 +167,31 @@ private constructor( fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) /** The dimensions that this dimensional price group is defined over */ - fun dimensions(dimensions: JsonField>) = apply { this.dimensions = dimensions } + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** The dimensions that this dimensional price group is defined over */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } + } + + /** An alias for the dimensional price group */ + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String?) = + externalDimensionalPriceGroupId(JsonField.ofNullable(externalDimensionalPriceGroupId)) /** An alias for the dimensional price group */ - fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String) = - externalDimensionalPriceGroupId(JsonField.of(externalDimensionalPriceGroupId)) + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: Optional) = + externalDimensionalPriceGroupId(externalDimensionalPriceGroupId.orElse(null)) /** An alias for the dimensional price group */ fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: JsonField) = @@ -216,12 +240,15 @@ private constructor( fun build(): DimensionalPriceGroup = DimensionalPriceGroup( - id, - billableMetricId, - dimensions.map { it.toImmutable() }, - externalDimensionalPriceGroupId, - metadata, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetricId) { "`billableMetricId` is required but was not set" }, + checkNotNull(dimensions) { "`dimensions` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(externalDimensionalPriceGroupId) { + "`externalDimensionalPriceGroupId` is required but was not set" + }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt index fd5c7e13..3d4499f2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,15 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * A dimensional price group is used to partition the result of a billable metric by a set of + * dimensions. Prices in a price group must specify the parition used to derive their usage. + * + * For example, suppose we have a billable metric that measures the number of widgets used and we + * want to charge differently depending on the color of the widget. We can create a price group with + * a dimension "color" and two prices: one that charges $10 per red widget and one that charges $20 + * per blue widget. + */ class DimensionalPriceGroupCreateParams constructor( private val body: DimensionalPriceGroupCreateBody, @@ -39,12 +50,29 @@ constructor( */ fun metadata(): Optional = body.metadata() - fun _additionalHeaders(): Headers = additionalHeaders + fun _billableMetricId(): JsonField = body._billableMetricId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The set of keys (in order) used to disambiguate prices in the group. */ + fun _dimensions(): JsonField> = body._dimensions() + + fun _name(): JsonField = body._name() + + fun _externalDimensionalPriceGroupId(): JsonField = + body._externalDimensionalPriceGroupId() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): DimensionalPriceGroupCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -55,38 +83,83 @@ constructor( class DimensionalPriceGroupCreateBody @JsonCreator internal constructor( - @JsonProperty("billable_metric_id") private val billableMetricId: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("name") private val name: String, + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("external_dimensional_price_group_id") - private val externalDimensionalPriceGroupId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val externalDimensionalPriceGroupId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("billable_metric_id") fun billableMetricId(): String = billableMetricId + fun billableMetricId(): String = billableMetricId.getRequired("billable_metric_id") /** The set of keys (in order) used to disambiguate prices in the group. */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + fun dimensions(): List = dimensions.getRequired("dimensions") - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("external_dimensional_price_group_id") fun externalDimensionalPriceGroupId(): Optional = - Optional.ofNullable(externalDimensionalPriceGroupId) + Optional.ofNullable( + externalDimensionalPriceGroupId.getNullable("external_dimensional_price_group_id") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** The set of keys (in order) used to disambiguate prices in the group. */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("external_dimensional_price_group_id") + @ExcludeMissing + fun _externalDimensionalPriceGroupId(): JsonField = externalDimensionalPriceGroupId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): DimensionalPriceGroupCreateBody = apply { + if (!validated) { + billableMetricId() + dimensions() + name() + externalDimensionalPriceGroupId() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -96,18 +169,19 @@ constructor( class Builder { - private var billableMetricId: String? = null - private var dimensions: MutableList? = null - private var name: String? = null - private var externalDimensionalPriceGroupId: String? = null - private var metadata: Metadata? = null + private var billableMetricId: JsonField? = null + private var dimensions: JsonField>? = null + private var name: JsonField? = null + private var externalDimensionalPriceGroupId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(dimensionalPriceGroupCreateBody: DimensionalPriceGroupCreateBody) = apply { billableMetricId = dimensionalPriceGroupCreateBody.billableMetricId - dimensions = dimensionalPriceGroupCreateBody.dimensions.toMutableList() + dimensions = + dimensionalPriceGroupCreateBody.dimensions.map { it.toMutableList() } name = dimensionalPriceGroupCreateBody.name externalDimensionalPriceGroupId = dimensionalPriceGroupCreateBody.externalDimensionalPriceGroupId @@ -116,35 +190,57 @@ constructor( dimensionalPriceGroupCreateBody.additionalProperties.toMutableMap() } - fun billableMetricId(billableMetricId: String) = apply { + fun billableMetricId(billableMetricId: String) = + billableMetricId(JsonField.of(billableMetricId)) + + fun billableMetricId(billableMetricId: JsonField) = apply { this.billableMetricId = billableMetricId } /** The set of keys (in order) used to disambiguate prices in the group. */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + + /** The set of keys (in order) used to disambiguate prices in the group. */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** The set of keys (in order) used to disambiguate prices in the group. */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String?) = apply { - this.externalDimensionalPriceGroupId = externalDimensionalPriceGroupId - } + fun name(name: JsonField) = apply { this.name = name } + + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String?) = + externalDimensionalPriceGroupId( + JsonField.ofNullable(externalDimensionalPriceGroupId) + ) fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: Optional) = externalDimensionalPriceGroupId(externalDimensionalPriceGroupId.orElse(null)) + fun externalDimensionalPriceGroupId( + externalDimensionalPriceGroupId: JsonField + ) = apply { this.externalDimensionalPriceGroupId = externalDimensionalPriceGroupId } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -153,6 +249,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -178,7 +281,7 @@ constructor( "`billableMetricId` is required but was not set" }, checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(name) { "`name` is required but was not set" }, externalDimensionalPriceGroupId, metadata, @@ -232,14 +335,23 @@ constructor( body.billableMetricId(billableMetricId) } + fun billableMetricId(billableMetricId: JsonField) = apply { + body.billableMetricId(billableMetricId) + } + /** The set of keys (in order) used to disambiguate prices in the group. */ fun dimensions(dimensions: List) = apply { body.dimensions(dimensions) } + /** The set of keys (in order) used to disambiguate prices in the group. */ + fun dimensions(dimensions: JsonField>) = apply { body.dimensions(dimensions) } + /** The set of keys (in order) used to disambiguate prices in the group. */ fun addDimension(dimension: String) = apply { body.addDimension(dimension) } fun name(name: String) = apply { body.name(name) } + fun name(name: JsonField) = apply { body.name(name) } + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: String?) = apply { body.externalDimensionalPriceGroupId(externalDimensionalPriceGroupId) } @@ -247,6 +359,11 @@ constructor( fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: Optional) = externalDimensionalPriceGroupId(externalDimensionalPriceGroupId.orElse(null)) + fun externalDimensionalPriceGroupId(externalDimensionalPriceGroupId: JsonField) = + apply { + body.externalDimensionalPriceGroupId(externalDimensionalPriceGroupId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -261,6 +378,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -359,25 +502,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): DimensionalPriceGroupCreateParams = DimensionalPriceGroupCreateParams( body.build(), @@ -403,6 +527,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt index cbefe11c..be93ebe9 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams.kt @@ -7,6 +7,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** Fetch dimensional price group by external ID */ class DimensionalPriceGroupExternalDimensionalPriceGroupIdRetrieveParams constructor( private val externalDimensionalPriceGroupId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt index 49453030..62c04965 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupListParams.kt @@ -8,6 +8,7 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** List dimensional price groups */ class DimensionalPriceGroupListParams constructor( private val cursor: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt index 1c9e6897..ec70cde1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroupRetrieveParams.kt @@ -7,6 +7,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** Fetch dimensional price group */ class DimensionalPriceGroupRetrieveParams constructor( private val dimensionalPriceGroupId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt index e4a8d5c9..d9fc0418 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/DimensionalPriceGroups.kt @@ -33,11 +33,11 @@ private constructor( fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonProperty("pagination_metadata") @ExcludeMissing - fun _paginationMetadata() = paginationMetadata + fun _paginationMetadata(): JsonField = paginationMetadata @JsonAnyGetter @ExcludeMissing @@ -62,20 +62,35 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() - private var paginationMetadata: JsonField = JsonMissing.of() + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(dimensionalPriceGroups: DimensionalPriceGroups) = apply { - data = dimensionalPriceGroups.data + data = dimensionalPriceGroups.data.map { it.toMutableList() } paginationMetadata = dimensionalPriceGroups.paginationMetadata additionalProperties = dimensionalPriceGroups.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: DimensionalPriceGroup) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -105,8 +120,11 @@ private constructor( fun build(): DimensionalPriceGroups = DimensionalPriceGroups( - data.map { it.toImmutable() }, - paginationMetadata, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(paginationMetadata) { + "`paginationMetadata` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt index 2ce7d025..f23bcb84 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Discount.kt @@ -248,17 +248,21 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** * Only available if discount_type is `usage`. Number of usage units that this discount is * for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -285,15 +289,15 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var usageDiscount: JsonField? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscount: UsageDiscount) = apply { - appliesToPriceIds = usageDiscount.appliesToPriceIds + appliesToPriceIds = usageDiscount.appliesToPriceIds.map { it.toMutableList() } discountType = usageDiscount.discountType this.usageDiscount = usageDiscount.usageDiscount reason = usageDiscount.reason @@ -312,7 +316,24 @@ private constructor( * can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this + * can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -335,7 +356,9 @@ private constructor( this.usageDiscount = usageDiscount } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -360,9 +383,12 @@ private constructor( fun build(): UsageDiscount = UsageDiscount( - appliesToPriceIds.map { it.toImmutable() }, - discountType, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(usageDiscount) { "`usageDiscount` is required but was not set" }, reason, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt index 2393d25a..6d778468 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EvaluatePriceGroup.kt @@ -53,13 +53,15 @@ private constructor( fun quantity(): Double = quantity.getRequired("quantity") /** The price's output for the group */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The values for the group in the order specified by `grouping_keys` */ - @JsonProperty("grouping_values") @ExcludeMissing fun _groupingValues() = groupingValues + @JsonProperty("grouping_values") + @ExcludeMissing + fun _groupingValues(): JsonField> = groupingValues /** The price's usage quantity for the group */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -85,15 +87,15 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var groupingValues: JsonField> = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var groupingValues: JsonField>? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(evaluatePriceGroup: EvaluatePriceGroup) = apply { amount = evaluatePriceGroup.amount - groupingValues = evaluatePriceGroup.groupingValues + groupingValues = evaluatePriceGroup.groupingValues.map { it.toMutableList() } quantity = evaluatePriceGroup.quantity additionalProperties = evaluatePriceGroup.additionalProperties.toMutableMap() } @@ -110,7 +112,21 @@ private constructor( /** The values for the group in the order specified by `grouping_keys` */ fun groupingValues(groupingValues: JsonField>) = apply { - this.groupingValues = groupingValues + this.groupingValues = groupingValues.map { it.toMutableList() } + } + + /** The values for the group in the order specified by `grouping_keys` */ + fun addGroupingValue(groupingValue: GroupingValue) = apply { + groupingValues = + (groupingValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(groupingValue) + } } /** The price's usage quantity for the group */ @@ -140,9 +156,10 @@ private constructor( fun build(): EvaluatePriceGroup = EvaluatePriceGroup( - amount, - groupingValues.map { it.toImmutable() }, - quantity, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(groupingValues) { "`groupingValues` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt index b7032634..ad84ec37 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseParams.kt @@ -10,6 +10,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * Closing a backfill makes the updated usage visible in Orb. Upon closing a backfill, Orb will + * asynchronously reflect the updated usage in invoice amounts and usage graphs. Once all of the + * updates are complete, the backfill's status will transition to `reflected`. + */ class EventBackfillCloseParams constructor( private val backfillId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt index 5fe6c161..ebd49557 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCloseResponse.kt @@ -96,40 +96,54 @@ private constructor( fun deprecationFilter(): Optional = Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * If in the future, the time at which the backfill will automatically close. If in the past, * the time at which the backfill was closed. */ - @JsonProperty("close_time") @ExcludeMissing fun _closeTime() = closeTime + @JsonProperty("close_time") + @ExcludeMissing + fun _closeTime(): JsonField = closeTime - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") @ExcludeMissing fun _eventsIngested() = eventsIngested + @JsonProperty("events_ingested") + @ExcludeMissing + fun _eventsIngested(): JsonField = eventsIngested /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") @ExcludeMissing fun _revertedAt() = revertedAt + @JsonProperty("reverted_at") + @ExcludeMissing + fun _revertedAt(): JsonField = revertedAt /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the set of events to deprecate */ - @JsonProperty("deprecation_filter") @ExcludeMissing fun _deprecationFilter() = deprecationFilter + @JsonProperty("deprecation_filter") + @ExcludeMissing + fun _deprecationFilter(): JsonField = deprecationFilter @JsonAnyGetter @ExcludeMissing @@ -162,15 +176,15 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var closeTime: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var eventsIngested: JsonField = JsonMissing.of() - private var revertedAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var closeTime: JsonField? = null + private var createdAt: JsonField? = null + private var customerId: JsonField? = null + private var eventsIngested: JsonField? = null + private var revertedAt: JsonField? = null + private var status: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var deprecationFilter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -197,7 +211,13 @@ private constructor( * If in the future, the time at which the backfill will automatically close. If in the * past, the time at which the backfill was closed. */ - fun closeTime(closeTime: OffsetDateTime) = closeTime(JsonField.of(closeTime)) + fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) + + /** + * If in the future, the time at which the backfill will automatically close. If in the + * past, the time at which the backfill was closed. + */ + fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) /** * If in the future, the time at which the backfill will automatically close. If in the @@ -213,7 +233,13 @@ private constructor( * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this + * backfill is scoped to all customers. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this @@ -230,7 +256,10 @@ private constructor( } /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime) = revertedAt(JsonField.of(revertedAt)) + fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) + + /** The time at which this backfill was reverted. */ + fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) /** The time at which this backfill was reverted. */ fun revertedAt(revertedAt: JsonField) = apply { @@ -261,8 +290,16 @@ private constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to * filter the set of events to deprecate */ - fun deprecationFilter(deprecationFilter: String) = - deprecationFilter(JsonField.of(deprecationFilter)) + fun deprecationFilter(deprecationFilter: String?) = + deprecationFilter(JsonField.ofNullable(deprecationFilter)) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: Optional) = + deprecationFilter(deprecationFilter.orElse(null)) /** * A boolean @@ -294,15 +331,15 @@ private constructor( fun build(): EventBackfillCloseResponse = EventBackfillCloseResponse( - id, - closeTime, - createdAt, - customerId, - eventsIngested, - revertedAt, - status, - timeframeEnd, - timeframeStart, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(closeTime) { "`closeTime` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(eventsIngested) { "`eventsIngested` is required but was not set" }, + checkNotNull(revertedAt) { "`revertedAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, deprecationFilter, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt index 40e0aa63..e07a6c93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,36 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * Creating the backfill enables adding or replacing past events, even those that are older than the + * ingestion grace period. Performing a backfill in Orb involves 3 steps: + * 1. Create the backfill, specifying its parameters. + * 2. [Ingest](ingest) usage events, referencing the backfill (query parameter `backfill_id`). + * 3. [Close](close-backfill) the backfill, propagating the update in past usage throughout Orb. + * + * Changes from a backfill are not reflected until the backfill is closed, so you won’t need to + * worry about your customers seeing partially updated usage data. Backfills are also reversible, so + * you’ll be able to revert a backfill if you’ve made a mistake. + * + * This endpoint will return a backfill object, which contains an `id`. That `id` can then be used + * as the `backfill_id` query parameter to the event ingestion endpoint to associate ingested events + * with this backfill. The effects (e.g. updated usage graphs) of this backfill will not take place + * until the backfill is closed. + * + * If the `replace_existing_events` is `true`, existing events in the backfill's timeframe will be + * replaced with the newly ingested events associated with the backfill. If `false`, newly ingested + * events will be added to the existing events. + * + * If a `customer_id` or `external_customer_id` is specified, the backfill will only affect events + * for that customer. If neither is specified, the backfill will affect all customers. + * + * When `replace_existing_events` is `true`, this indicates that existing events in the timeframe + * should no longer be counted towards invoiced usage. In this scenario, the parameter `filter` can + * be optionally added which enables filtering using + * [computed properties](../guides/extensibility/advanced-metrics#computed-properties). The + * expressiveness of computed properties allows you to deprecate existing events based on both a + * period of time and specific property values. + */ class EventBackfillCreateParams constructor( private val body: EventBackfillCreateBody, @@ -61,12 +93,49 @@ constructor( */ fun replaceExistingEvents(): Optional = body.replaceExistingEvents() - fun _additionalHeaders(): Headers = additionalHeaders + /** The (exclusive) end of the usage timeframe affected by this backfill. */ + fun _timeframeEnd(): JsonField = body._timeframeEnd() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The (inclusive) start of the usage timeframe affected by this backfill. */ + fun _timeframeStart(): JsonField = body._timeframeStart() + + /** + * The time at which no more events will be accepted for this backfill. The backfill will + * automatically begin reflecting throughout Orb at the close time. If not specified, it will + * default to 1 day after the creation of the backfill. + */ + fun _closeTime(): JsonField = body._closeTime() + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this field + * will scope the backfill to all customers. + */ + fun _customerId(): JsonField = body._customerId() + + /** + * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) + * used to filter the set of events to deprecate + */ + fun _deprecationFilter(): JsonField = body._deprecationFilter() + + /** + * The external customer ID of the customer to which this backfill is scoped. Omitting this + * field will scope the backfill to all customers. + */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + /** + * If true, replaces all existing events in the timeframe with the newly ingested events. If + * false, adds the newly ingested events to the existing events. + */ + fun _replaceExistingEvents(): JsonField = body._replaceExistingEvents() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): EventBackfillCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -77,22 +146,83 @@ constructor( class EventBackfillCreateBody @JsonCreator internal constructor( - @JsonProperty("timeframe_end") private val timeframeEnd: OffsetDateTime, - @JsonProperty("timeframe_start") private val timeframeStart: OffsetDateTime, - @JsonProperty("close_time") private val closeTime: OffsetDateTime?, - @JsonProperty("customer_id") private val customerId: String?, - @JsonProperty("deprecation_filter") private val deprecationFilter: String?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("replace_existing_events") private val replaceExistingEvents: Boolean?, + @JsonProperty("timeframe_end") + @ExcludeMissing + private val timeframeEnd: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_start") + @ExcludeMissing + private val timeframeStart: JsonField = JsonMissing.of(), + @JsonProperty("close_time") + @ExcludeMissing + private val closeTime: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("deprecation_filter") + @ExcludeMissing + private val deprecationFilter: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("replace_existing_events") + @ExcludeMissing + private val replaceExistingEvents: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The (exclusive) end of the usage timeframe affected by this backfill. */ - @JsonProperty("timeframe_end") fun timeframeEnd(): OffsetDateTime = timeframeEnd + fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") /** The (inclusive) start of the usage timeframe affected by this backfill. */ - @JsonProperty("timeframe_start") fun timeframeStart(): OffsetDateTime = timeframeStart + fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") + + /** + * The time at which no more events will be accepted for this backfill. The backfill will + * automatically begin reflecting throughout Orb at the close time. If not specified, it + * will default to 1 day after the creation of the backfill. + */ + fun closeTime(): Optional = + Optional.ofNullable(closeTime.getNullable("close_time")) + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this + * field will scope the backfill to all customers. + */ + fun customerId(): Optional = + Optional.ofNullable(customerId.getNullable("customer_id")) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(): Optional = + Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) + + /** + * The external customer ID of the customer to which this backfill is scoped. Omitting this + * field will scope the backfill to all customers. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** + * If true, replaces all existing events in the timeframe with the newly ingested events. If + * false, adds the newly ingested events to the existing events. + */ + fun replaceExistingEvents(): Optional = + Optional.ofNullable(replaceExistingEvents.getNullable("replace_existing_events")) + + /** The (exclusive) end of the usage timeframe affected by this backfill. */ + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd + + /** The (inclusive) start of the usage timeframe affected by this backfill. */ + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** * The time at which no more events will be accepted for this backfill. The backfill will @@ -100,14 +230,16 @@ constructor( * will default to 1 day after the creation of the backfill. */ @JsonProperty("close_time") - fun closeTime(): Optional = Optional.ofNullable(closeTime) + @ExcludeMissing + fun _closeTime(): JsonField = closeTime /** * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this * field will scope the backfill to all customers. */ @JsonProperty("customer_id") - fun customerId(): Optional = Optional.ofNullable(customerId) + @ExcludeMissing + fun _customerId(): JsonField = customerId /** * A boolean @@ -115,26 +247,44 @@ constructor( * filter the set of events to deprecate */ @JsonProperty("deprecation_filter") - fun deprecationFilter(): Optional = Optional.ofNullable(deprecationFilter) + @ExcludeMissing + fun _deprecationFilter(): JsonField = deprecationFilter /** * The external customer ID of the customer to which this backfill is scoped. Omitting this * field will scope the backfill to all customers. */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId /** * If true, replaces all existing events in the timeframe with the newly ingested events. If * false, adds the newly ingested events to the existing events. */ @JsonProperty("replace_existing_events") - fun replaceExistingEvents(): Optional = Optional.ofNullable(replaceExistingEvents) + @ExcludeMissing + fun _replaceExistingEvents(): JsonField = replaceExistingEvents @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventBackfillCreateBody = apply { + if (!validated) { + timeframeEnd() + timeframeStart() + closeTime() + customerId() + deprecationFilter() + externalCustomerId() + replaceExistingEvents() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -144,13 +294,13 @@ constructor( class Builder { - private var timeframeEnd: OffsetDateTime? = null - private var timeframeStart: OffsetDateTime? = null - private var closeTime: OffsetDateTime? = null - private var customerId: String? = null - private var deprecationFilter: String? = null - private var externalCustomerId: String? = null - private var replaceExistingEvents: Boolean? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var closeTime: JsonField = JsonMissing.of() + private var customerId: JsonField = JsonMissing.of() + private var deprecationFilter: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var replaceExistingEvents: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -166,12 +316,20 @@ constructor( } /** The (exclusive) end of the usage timeframe affected by this backfill. */ - fun timeframeEnd(timeframeEnd: OffsetDateTime) = apply { + fun timeframeEnd(timeframeEnd: OffsetDateTime) = + timeframeEnd(JsonField.of(timeframeEnd)) + + /** The (exclusive) end of the usage timeframe affected by this backfill. */ + fun timeframeEnd(timeframeEnd: JsonField) = apply { this.timeframeEnd = timeframeEnd } /** The (inclusive) start of the usage timeframe affected by this backfill. */ - fun timeframeStart(timeframeStart: OffsetDateTime) = apply { + fun timeframeStart(timeframeStart: OffsetDateTime) = + timeframeStart(JsonField.of(timeframeStart)) + + /** The (inclusive) start of the usage timeframe affected by this backfill. */ + fun timeframeStart(timeframeStart: JsonField) = apply { this.timeframeStart = timeframeStart } @@ -180,7 +338,7 @@ constructor( * will automatically begin reflecting throughout Orb at the close time. If not * specified, it will default to 1 day after the creation of the backfill. */ - fun closeTime(closeTime: OffsetDateTime?) = apply { this.closeTime = closeTime } + fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) /** * The time at which no more events will be accepted for this backfill. The backfill @@ -189,11 +347,20 @@ constructor( */ fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) + /** + * The time at which no more events will be accepted for this backfill. The backfill + * will automatically begin reflecting throughout Orb at the close time. If not + * specified, it will default to 1 day after the creation of the backfill. + */ + fun closeTime(closeTime: JsonField) = apply { + this.closeTime = closeTime + } + /** * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this * field will scope the backfill to all customers. */ - fun customerId(customerId: String?) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this @@ -201,14 +368,19 @@ constructor( */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** + * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this + * field will scope the backfill to all customers. + */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** * A boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the set of events to deprecate */ - fun deprecationFilter(deprecationFilter: String?) = apply { - this.deprecationFilter = deprecationFilter - } + fun deprecationFilter(deprecationFilter: String?) = + deprecationFilter(JsonField.ofNullable(deprecationFilter)) /** * A boolean @@ -218,13 +390,21 @@ constructor( fun deprecationFilter(deprecationFilter: Optional) = deprecationFilter(deprecationFilter.orElse(null)) + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) + * used to filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: JsonField) = apply { + this.deprecationFilter = deprecationFilter + } + /** * The external customer ID of the customer to which this backfill is scoped. Omitting * this field will scope the backfill to all customers. */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * The external customer ID of the customer to which this backfill is scoped. Omitting @@ -234,11 +414,11 @@ constructor( externalCustomerId(externalCustomerId.orElse(null)) /** - * If true, replaces all existing events in the timeframe with the newly ingested - * events. If false, adds the newly ingested events to the existing events. + * The external customer ID of the customer to which this backfill is scoped. Omitting + * this field will scope the backfill to all customers. */ - fun replaceExistingEvents(replaceExistingEvents: Boolean?) = apply { - this.replaceExistingEvents = replaceExistingEvents + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId } /** @@ -246,15 +426,15 @@ constructor( * events. If false, adds the newly ingested events to the existing events. */ fun replaceExistingEvents(replaceExistingEvents: Boolean) = - replaceExistingEvents(replaceExistingEvents as Boolean?) + replaceExistingEvents(JsonField.of(replaceExistingEvents)) /** * If true, replaces all existing events in the timeframe with the newly ingested * events. If false, adds the newly ingested events to the existing events. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun replaceExistingEvents(replaceExistingEvents: Optional) = - replaceExistingEvents(replaceExistingEvents.orElse(null) as Boolean?) + fun replaceExistingEvents(replaceExistingEvents: JsonField) = apply { + this.replaceExistingEvents = replaceExistingEvents + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -330,11 +510,21 @@ constructor( /** The (exclusive) end of the usage timeframe affected by this backfill. */ fun timeframeEnd(timeframeEnd: OffsetDateTime) = apply { body.timeframeEnd(timeframeEnd) } + /** The (exclusive) end of the usage timeframe affected by this backfill. */ + fun timeframeEnd(timeframeEnd: JsonField) = apply { + body.timeframeEnd(timeframeEnd) + } + /** The (inclusive) start of the usage timeframe affected by this backfill. */ fun timeframeStart(timeframeStart: OffsetDateTime) = apply { body.timeframeStart(timeframeStart) } + /** The (inclusive) start of the usage timeframe affected by this backfill. */ + fun timeframeStart(timeframeStart: JsonField) = apply { + body.timeframeStart(timeframeStart) + } + /** * The time at which no more events will be accepted for this backfill. The backfill will * automatically begin reflecting throughout Orb at the close time. If not specified, it @@ -349,6 +539,13 @@ constructor( */ fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) + /** + * The time at which no more events will be accepted for this backfill. The backfill will + * automatically begin reflecting throughout Orb at the close time. If not specified, it + * will default to 1 day after the creation of the backfill. + */ + fun closeTime(closeTime: JsonField) = apply { body.closeTime(closeTime) } + /** * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this * field will scope the backfill to all customers. @@ -361,6 +558,12 @@ constructor( */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** + * The Orb-generated ID of the customer to which this backfill is scoped. Omitting this + * field will scope the backfill to all customers. + */ + fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + /** * A boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to @@ -378,6 +581,15 @@ constructor( fun deprecationFilter(deprecationFilter: Optional) = deprecationFilter(deprecationFilter.orElse(null)) + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: JsonField) = apply { + body.deprecationFilter(deprecationFilter) + } + /** * The external customer ID of the customer to which this backfill is scoped. Omitting this * field will scope the backfill to all customers. @@ -394,27 +606,47 @@ constructor( externalCustomerId(externalCustomerId.orElse(null)) /** - * If true, replaces all existing events in the timeframe with the newly ingested events. If - * false, adds the newly ingested events to the existing events. + * The external customer ID of the customer to which this backfill is scoped. Omitting this + * field will scope the backfill to all customers. */ - fun replaceExistingEvents(replaceExistingEvents: Boolean?) = apply { - body.replaceExistingEvents(replaceExistingEvents) + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) } /** * If true, replaces all existing events in the timeframe with the newly ingested events. If * false, adds the newly ingested events to the existing events. */ - fun replaceExistingEvents(replaceExistingEvents: Boolean) = - replaceExistingEvents(replaceExistingEvents as Boolean?) + fun replaceExistingEvents(replaceExistingEvents: Boolean) = apply { + body.replaceExistingEvents(replaceExistingEvents) + } /** * If true, replaces all existing events in the timeframe with the newly ingested events. If * false, adds the newly ingested events to the existing events. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun replaceExistingEvents(replaceExistingEvents: Optional) = - replaceExistingEvents(replaceExistingEvents.orElse(null) as Boolean?) + fun replaceExistingEvents(replaceExistingEvents: JsonField) = apply { + body.replaceExistingEvents(replaceExistingEvents) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -514,25 +746,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): EventBackfillCreateParams = EventBackfillCreateParams( body.build(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt index ddc3fdd2..66bad85a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillCreateResponse.kt @@ -96,40 +96,54 @@ private constructor( fun deprecationFilter(): Optional = Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * If in the future, the time at which the backfill will automatically close. If in the past, * the time at which the backfill was closed. */ - @JsonProperty("close_time") @ExcludeMissing fun _closeTime() = closeTime + @JsonProperty("close_time") + @ExcludeMissing + fun _closeTime(): JsonField = closeTime - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") @ExcludeMissing fun _eventsIngested() = eventsIngested + @JsonProperty("events_ingested") + @ExcludeMissing + fun _eventsIngested(): JsonField = eventsIngested /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") @ExcludeMissing fun _revertedAt() = revertedAt + @JsonProperty("reverted_at") + @ExcludeMissing + fun _revertedAt(): JsonField = revertedAt /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the set of events to deprecate */ - @JsonProperty("deprecation_filter") @ExcludeMissing fun _deprecationFilter() = deprecationFilter + @JsonProperty("deprecation_filter") + @ExcludeMissing + fun _deprecationFilter(): JsonField = deprecationFilter @JsonAnyGetter @ExcludeMissing @@ -162,15 +176,15 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var closeTime: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var eventsIngested: JsonField = JsonMissing.of() - private var revertedAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var closeTime: JsonField? = null + private var createdAt: JsonField? = null + private var customerId: JsonField? = null + private var eventsIngested: JsonField? = null + private var revertedAt: JsonField? = null + private var status: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var deprecationFilter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -197,7 +211,13 @@ private constructor( * If in the future, the time at which the backfill will automatically close. If in the * past, the time at which the backfill was closed. */ - fun closeTime(closeTime: OffsetDateTime) = closeTime(JsonField.of(closeTime)) + fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) + + /** + * If in the future, the time at which the backfill will automatically close. If in the + * past, the time at which the backfill was closed. + */ + fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) /** * If in the future, the time at which the backfill will automatically close. If in the @@ -213,7 +233,13 @@ private constructor( * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this + * backfill is scoped to all customers. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this @@ -230,7 +256,10 @@ private constructor( } /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime) = revertedAt(JsonField.of(revertedAt)) + fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) + + /** The time at which this backfill was reverted. */ + fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) /** The time at which this backfill was reverted. */ fun revertedAt(revertedAt: JsonField) = apply { @@ -261,8 +290,16 @@ private constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to * filter the set of events to deprecate */ - fun deprecationFilter(deprecationFilter: String) = - deprecationFilter(JsonField.of(deprecationFilter)) + fun deprecationFilter(deprecationFilter: String?) = + deprecationFilter(JsonField.ofNullable(deprecationFilter)) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: Optional) = + deprecationFilter(deprecationFilter.orElse(null)) /** * A boolean @@ -294,15 +331,15 @@ private constructor( fun build(): EventBackfillCreateResponse = EventBackfillCreateResponse( - id, - closeTime, - createdAt, - customerId, - eventsIngested, - revertedAt, - status, - timeframeEnd, - timeframeStart, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(closeTime) { "`closeTime` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(eventsIngested) { "`eventsIngested` is required but was not set" }, + checkNotNull(revertedAt) { "`revertedAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, deprecationFilter, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt index fc90e84e..60548af8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchParams.kt @@ -7,6 +7,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** This endpoint is used to fetch a backfill given an identifier. */ class EventBackfillFetchParams constructor( private val backfillId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt index 5cb414a5..def03bad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillFetchResponse.kt @@ -96,40 +96,54 @@ private constructor( fun deprecationFilter(): Optional = Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * If in the future, the time at which the backfill will automatically close. If in the past, * the time at which the backfill was closed. */ - @JsonProperty("close_time") @ExcludeMissing fun _closeTime() = closeTime + @JsonProperty("close_time") + @ExcludeMissing + fun _closeTime(): JsonField = closeTime - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") @ExcludeMissing fun _eventsIngested() = eventsIngested + @JsonProperty("events_ingested") + @ExcludeMissing + fun _eventsIngested(): JsonField = eventsIngested /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") @ExcludeMissing fun _revertedAt() = revertedAt + @JsonProperty("reverted_at") + @ExcludeMissing + fun _revertedAt(): JsonField = revertedAt /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the set of events to deprecate */ - @JsonProperty("deprecation_filter") @ExcludeMissing fun _deprecationFilter() = deprecationFilter + @JsonProperty("deprecation_filter") + @ExcludeMissing + fun _deprecationFilter(): JsonField = deprecationFilter @JsonAnyGetter @ExcludeMissing @@ -162,15 +176,15 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var closeTime: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var eventsIngested: JsonField = JsonMissing.of() - private var revertedAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var closeTime: JsonField? = null + private var createdAt: JsonField? = null + private var customerId: JsonField? = null + private var eventsIngested: JsonField? = null + private var revertedAt: JsonField? = null + private var status: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var deprecationFilter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -197,7 +211,13 @@ private constructor( * If in the future, the time at which the backfill will automatically close. If in the * past, the time at which the backfill was closed. */ - fun closeTime(closeTime: OffsetDateTime) = closeTime(JsonField.of(closeTime)) + fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) + + /** + * If in the future, the time at which the backfill will automatically close. If in the + * past, the time at which the backfill was closed. + */ + fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) /** * If in the future, the time at which the backfill will automatically close. If in the @@ -213,7 +233,13 @@ private constructor( * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this + * backfill is scoped to all customers. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this @@ -230,7 +256,10 @@ private constructor( } /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime) = revertedAt(JsonField.of(revertedAt)) + fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) + + /** The time at which this backfill was reverted. */ + fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) /** The time at which this backfill was reverted. */ fun revertedAt(revertedAt: JsonField) = apply { @@ -261,8 +290,16 @@ private constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to * filter the set of events to deprecate */ - fun deprecationFilter(deprecationFilter: String) = - deprecationFilter(JsonField.of(deprecationFilter)) + fun deprecationFilter(deprecationFilter: String?) = + deprecationFilter(JsonField.ofNullable(deprecationFilter)) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: Optional) = + deprecationFilter(deprecationFilter.orElse(null)) /** * A boolean @@ -294,15 +331,15 @@ private constructor( fun build(): EventBackfillFetchResponse = EventBackfillFetchResponse( - id, - closeTime, - createdAt, - customerId, - eventsIngested, - revertedAt, - status, - timeframeEnd, - timeframeStart, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(closeTime) { "`closeTime` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(eventsIngested) { "`eventsIngested` is required but was not set" }, + checkNotNull(revertedAt) { "`revertedAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, deprecationFilter, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt index 40adf5c5..dd55dab5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListParams.kt @@ -8,6 +8,14 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all backfills in a list format. + * + * The list of backfills is ordered starting from the most recently created backfill. The response + * also includes [`pagination_metadata`](../reference/pagination), which lets the caller retrieve + * the next page of results if they exist. More information about pagination can be found in the + * [Pagination-metadata schema](pagination). + */ class EventBackfillListParams constructor( private val cursor: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt index 0ba3a719..b82d4048 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillListResponse.kt @@ -96,40 +96,54 @@ private constructor( fun deprecationFilter(): Optional = Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * If in the future, the time at which the backfill will automatically close. If in the past, * the time at which the backfill was closed. */ - @JsonProperty("close_time") @ExcludeMissing fun _closeTime() = closeTime + @JsonProperty("close_time") + @ExcludeMissing + fun _closeTime(): JsonField = closeTime - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") @ExcludeMissing fun _eventsIngested() = eventsIngested + @JsonProperty("events_ingested") + @ExcludeMissing + fun _eventsIngested(): JsonField = eventsIngested /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") @ExcludeMissing fun _revertedAt() = revertedAt + @JsonProperty("reverted_at") + @ExcludeMissing + fun _revertedAt(): JsonField = revertedAt /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the set of events to deprecate */ - @JsonProperty("deprecation_filter") @ExcludeMissing fun _deprecationFilter() = deprecationFilter + @JsonProperty("deprecation_filter") + @ExcludeMissing + fun _deprecationFilter(): JsonField = deprecationFilter @JsonAnyGetter @ExcludeMissing @@ -162,15 +176,15 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var closeTime: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var eventsIngested: JsonField = JsonMissing.of() - private var revertedAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var closeTime: JsonField? = null + private var createdAt: JsonField? = null + private var customerId: JsonField? = null + private var eventsIngested: JsonField? = null + private var revertedAt: JsonField? = null + private var status: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var deprecationFilter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -197,7 +211,13 @@ private constructor( * If in the future, the time at which the backfill will automatically close. If in the * past, the time at which the backfill was closed. */ - fun closeTime(closeTime: OffsetDateTime) = closeTime(JsonField.of(closeTime)) + fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) + + /** + * If in the future, the time at which the backfill will automatically close. If in the + * past, the time at which the backfill was closed. + */ + fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) /** * If in the future, the time at which the backfill will automatically close. If in the @@ -213,7 +233,13 @@ private constructor( * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this + * backfill is scoped to all customers. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this @@ -230,7 +256,10 @@ private constructor( } /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime) = revertedAt(JsonField.of(revertedAt)) + fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) + + /** The time at which this backfill was reverted. */ + fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) /** The time at which this backfill was reverted. */ fun revertedAt(revertedAt: JsonField) = apply { @@ -261,8 +290,16 @@ private constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to * filter the set of events to deprecate */ - fun deprecationFilter(deprecationFilter: String) = - deprecationFilter(JsonField.of(deprecationFilter)) + fun deprecationFilter(deprecationFilter: String?) = + deprecationFilter(JsonField.ofNullable(deprecationFilter)) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: Optional) = + deprecationFilter(deprecationFilter.orElse(null)) /** * A boolean @@ -294,15 +331,15 @@ private constructor( fun build(): EventBackfillListResponse = EventBackfillListResponse( - id, - closeTime, - createdAt, - customerId, - eventsIngested, - revertedAt, - status, - timeframeEnd, - timeframeStart, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(closeTime) { "`closeTime` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(eventsIngested) { "`eventsIngested` is required but was not set" }, + checkNotNull(revertedAt) { "`revertedAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, deprecationFilter, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt index e31bcd63..7869ed74 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertParams.kt @@ -10,6 +10,14 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * Reverting a backfill undoes all the effects of closing the backfill. If the backfill is + * reflected, the status will transition to `pending_revert` while the effects of the backfill are + * undone. Once all effects are undone, the backfill will transition to `reverted`. + * + * If a backfill is reverted before its closed, no usage will be updated as a result of the backfill + * and it will immediately transition to `reverted`. + */ class EventBackfillRevertParams constructor( private val backfillId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt index 40e14a1c..9b92704f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventBackfillRevertResponse.kt @@ -96,40 +96,54 @@ private constructor( fun deprecationFilter(): Optional = Optional.ofNullable(deprecationFilter.getNullable("deprecation_filter")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * If in the future, the time at which the backfill will automatically close. If in the past, * the time at which the backfill was closed. */ - @JsonProperty("close_time") @ExcludeMissing fun _closeTime() = closeTime + @JsonProperty("close_time") + @ExcludeMissing + fun _closeTime(): JsonField = closeTime - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") @ExcludeMissing fun _customerId(): JsonField = customerId /** The number of events ingested in this backfill. */ - @JsonProperty("events_ingested") @ExcludeMissing fun _eventsIngested() = eventsIngested + @JsonProperty("events_ingested") + @ExcludeMissing + fun _eventsIngested(): JsonField = eventsIngested /** The time at which this backfill was reverted. */ - @JsonProperty("reverted_at") @ExcludeMissing fun _revertedAt() = revertedAt + @JsonProperty("reverted_at") + @ExcludeMissing + fun _revertedAt(): JsonField = revertedAt /** The status of the backfill. */ - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the set of events to deprecate */ - @JsonProperty("deprecation_filter") @ExcludeMissing fun _deprecationFilter() = deprecationFilter + @JsonProperty("deprecation_filter") + @ExcludeMissing + fun _deprecationFilter(): JsonField = deprecationFilter @JsonAnyGetter @ExcludeMissing @@ -162,15 +176,15 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var closeTime: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var eventsIngested: JsonField = JsonMissing.of() - private var revertedAt: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var closeTime: JsonField? = null + private var createdAt: JsonField? = null + private var customerId: JsonField? = null + private var eventsIngested: JsonField? = null + private var revertedAt: JsonField? = null + private var status: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var deprecationFilter: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -197,7 +211,13 @@ private constructor( * If in the future, the time at which the backfill will automatically close. If in the * past, the time at which the backfill was closed. */ - fun closeTime(closeTime: OffsetDateTime) = closeTime(JsonField.of(closeTime)) + fun closeTime(closeTime: OffsetDateTime?) = closeTime(JsonField.ofNullable(closeTime)) + + /** + * If in the future, the time at which the backfill will automatically close. If in the + * past, the time at which the backfill was closed. + */ + fun closeTime(closeTime: Optional) = closeTime(closeTime.orElse(null)) /** * If in the future, the time at which the backfill will automatically close. If in the @@ -213,7 +233,13 @@ private constructor( * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this * backfill is scoped to all customers. */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** + * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this + * backfill is scoped to all customers. + */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** * The Orb-generated ID of the customer to which this backfill is scoped. If `null`, this @@ -230,7 +256,10 @@ private constructor( } /** The time at which this backfill was reverted. */ - fun revertedAt(revertedAt: OffsetDateTime) = revertedAt(JsonField.of(revertedAt)) + fun revertedAt(revertedAt: OffsetDateTime?) = revertedAt(JsonField.ofNullable(revertedAt)) + + /** The time at which this backfill was reverted. */ + fun revertedAt(revertedAt: Optional) = revertedAt(revertedAt.orElse(null)) /** The time at which this backfill was reverted. */ fun revertedAt(revertedAt: JsonField) = apply { @@ -261,8 +290,16 @@ private constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to * filter the set of events to deprecate */ - fun deprecationFilter(deprecationFilter: String) = - deprecationFilter(JsonField.of(deprecationFilter)) + fun deprecationFilter(deprecationFilter: String?) = + deprecationFilter(JsonField.ofNullable(deprecationFilter)) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the set of events to deprecate + */ + fun deprecationFilter(deprecationFilter: Optional) = + deprecationFilter(deprecationFilter.orElse(null)) /** * A boolean @@ -294,15 +331,15 @@ private constructor( fun build(): EventBackfillRevertResponse = EventBackfillRevertResponse( - id, - closeTime, - createdAt, - customerId, - eventsIngested, - revertedAt, - status, - timeframeEnd, - timeframeStart, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(closeTime) { "`closeTime` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(eventsIngested) { "`eventsIngested` is required but was not set" }, + checkNotNull(revertedAt) { "`revertedAt` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, deprecationFilter, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt index 03248703..4649dfaa 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateParams.kt @@ -10,6 +10,40 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint is used to deprecate a single usage event with a given `event_id`. `event_id` + * refers to the `idempotency_key` passed in during ingestion. + * + * This endpoint will mark the existing event as ignored. Note that if you attempt to re-ingest an + * event with the same `event_id` as a deprecated event, Orb will return an error. + * + * This is a powerful and audit-safe mechanism to retroactively deprecate a single event in cases + * where you need to: + * - no longer bill for an event that was improperly reported + * - no longer bill for an event based on the result of an external API call (e.g. call to a payment + * gateway failed and the user should not be billed) + * + * If you want to only change specific properties of an event, but keep the event as part of the + * billing calculation, use the [Amend event](amend-event) endpoint instead. + * + * This API is always audit-safe. The process will still retain the deprecated event, though it will + * be ignored for billing calculations. For auditing and data fidelity purposes, Orb never + * overwrites or permanently deletes ingested usage data. + * + * ## Request validation + * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is + * by design idempotent. On retryable errors, you should retry the request and assume the + * deprecation operation has not succeeded until receipt of a 2xx. + * - The event's `timestamp` must fall within the customer's current subscription's billing period, + * or within the grace period of the customer's current subscription's previous billing period. + * Orb does not allow deprecating events for billing periods that have already invoiced customers. + * - The `customer_id` or the `external_customer_id` of the original event ingestion request must + * identify a Customer resource within Orb, even if this event was ingested during the initial + * integration period. We do not allow deprecating events for customers not in the Orb system. + * - By default, no more than 100 events can be deprecated for a single customer in a 100 day + * period. For higher volume updates, consider using the [event backfill](create-backfill) + * endpoint. + */ class EventDeprecateParams constructor( private val eventId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt index 79456aaa..17997534 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventDeprecateResponse.kt @@ -29,7 +29,7 @@ private constructor( fun deprecated(): String = deprecated.getRequired("deprecated") /** event_id of the deprecated event, if successfully updated */ - @JsonProperty("deprecated") @ExcludeMissing fun _deprecated() = deprecated + @JsonProperty("deprecated") @ExcludeMissing fun _deprecated(): JsonField = deprecated @JsonAnyGetter @ExcludeMissing @@ -53,7 +53,7 @@ private constructor( class Builder { - private var deprecated: JsonField = JsonMissing.of() + private var deprecated: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -88,7 +88,10 @@ private constructor( } fun build(): EventDeprecateResponse = - EventDeprecateResponse(deprecated, additionalProperties.toImmutable()) + EventDeprecateResponse( + checkNotNull(deprecated) { "`deprecated` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt index 833c590a..b2bceb0e 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,192 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * Orb's event ingestion model and API is designed around two core principles: + * 1. **Data fidelity**: The accuracy of your billing model depends on a robust foundation of + * events. Orb's API protocol encourages usage patterns that ensure that your data is + * consistently complete and correct. + * 2. **Fast integration**: Sending events into Orb requires no tedious setup steps or explicit + * field schema for your event shape, making it instant to start streaming in usage in real-time. + * + * ## Event shape + * + * Events are the starting point for all usage calculations in the system, and are simple at their + * core: + * ```ts + * { + * // customer_id and external_customer_id are used to + * // attribute usage to a given Customer. Exactly one of these + * // should be specified in a given ingestion event. + * + * // `customer_id` is the Orb generated identifier for the Customer, + * // which is returned from the Create customer API call. + * customer_id: string, + * + * // external_customer_id is an alternate identifier which is associated + * // with a Customer at creation time. This is treated as an alias for + * // customer_id, and is usually set to an identifier native to your system. + * external_customer_id: string, + * + * // A string name identifying the event, usually a usage + * // action. By convention, this should not contain any whitespace. + * event_name: string, + * + * // An ISO 8601 format date with no timezone offset. + * // This should represent the time that usage occurred + * // and is important to attribute usage to a given + * // billing period. See the notes below on determining the timestamp. + * // e.g. 2020-12-09T16:09:53Z + * timestamp: string, + * + * // A unique value, generated by the client, that is + * // used to de-duplicate events. + * // Exactly one event with a given + * // idempotency key will be ingested, which allows for + * // safe request retries. + * idempotency_key: string + * + * // Optional custom metadata to attach to the event. + * // This might include a numeric value used for aggregation, + * // or a string/boolean value used for filtering. + * // The schema of this dictionary need not be pre-declared, and + * // properties can be added at any time. + * properties: { + * [key: string]?: string | number | boolean, + * }, + * } + * ``` + * + * ## Required fields + * + * Because events streamed to Orb are meant to be as flexible as possible, there are only a few + * required fields in every event. + * - We recommend that `idempotency_key` are unique strings that you generated with V4 UUIDs, but + * only require that they uniquely identify an event (i.e. don’t collide). + * - The `timestamp` field in the event body will be used to determine which billable period a given + * event falls into. For example, with a monthly billing cycle starting from the first of + * December, Orb will calculate metrics based on events that fall into the range `12-01 00:00:00 + * <= timestamp < 01-01 00:00:00`. + * + * ## Logging metadata + * + * Orb allows tagging events with metadata using a flexible properties dictionary. Since Orb does + * not enforce a rigid schema for this field-set, key-value pairs can be added dynamically as your + * events evolve. + * + * This dictionary can be helpful for a wide variety of use cases: + * - Numeric properties on events like `compute_time_ms` can later be inputs to our flexible query + * engine to determine usage. + * - Logging a region or cluster with each event can help you provide customers more granular + * visibility into their usage. + * + * We encourage logging this metadata with an eye towards future use cases to ensure full coverage + * for historical data. The datatype of the value in the properties dictionary is important for + * metric creation from an event source. Values that you wish to numerically aggregate should be of + * numeric type in the event. + * + * ## Determining event timestamp + * + * For cases where usage is being reported in real time as it is occurring, timestamp should + * correspond to the time that usage occurred. + * + * In cases where usage is reported in aggregate for a historical timeframe at a regular interval, + * we recommend setting the event `timestamp` to the midpoint of the interval. As an example, if you + * have an hourly reporter that sends data once an hour for the previous hour of usage, setting the + * `timestamp` to the half-hour mark will ensure that the usage is counted within the correct + * period. + * + * Note that other time-related fields (e.g. time elapsed) can be added to the properties dictionary + * as necessary. + * + * In cases where usage is reported in aggregate for a historical timeframe, the timestamp must be + * within the grace period set for your account. Events with `timestamp < current_time - + * grace_period` will not be accepted as a valid event, and will throw validation errors. Enforcing + * the grace period enables Orb to accurately map usage to the correct billing cycle and ensure that + * all usage is billed for in the corresponding billing period. + * + * In general, Orb does not expect events with future dated timestamps. In cases where the timestamp + * is at least 24 hours ahead of the current time, the event will not be accepted as a valid event, + * and will throw validation errors. + * + * ## Event validation + * + * Orb’s validation ensures that you recognize errors in your events as quickly as possible, and the + * API provides informative error messages to help you fix problems quickly. + * + * We validate the following: + * - Exactly one of `customer_id` and `external_customer_id` should be specified. + * - If the `customer_id` is specified, the customer in Orb must exist. + * - If the `external_customer_id` is specified, the customer in Orb does not need to exist. Events + * will be attributed to any future customers with the `external_customer_id` on subscription + * creation. + * - `timestamp` must conform to ISO 8601 and represent a timestamp at most 1 hour in the future. + * This timestamp should be sent in UTC timezone (no timezone offset). + * + * ## Idempotency and retry semantics + * + * Orb's idempotency guarantees allow you to implement safe retry logic in the event of network or + * machine failures, ensuring data fidelity. Each event in the request payload is associated with an + * idempotency key, and Orb guarantees that a single idempotency key will be successfully ingested + * at most once. Note that when Orb encounters events with duplicate idempotency keys and differing + * event bodies in a batch of events, the entire batch will be rejected. + * - Successful responses return a 200 HTTP status code. The response contains information about + * previously processed events. + * - Requests that return a `4xx` HTTP status code indicate a payload error and contain at least one + * event with a validation failure. An event with a validation failure can be re-sent to the + * ingestion endpoint (after the payload is fixed) with the original idempotency key since that + * key is not marked as processed. + * - Requests that return a `5xx` HTTP status code indicate a server-side failure. These requests + * should be retried in their entirety. + * + * ## API usage and limits + * + * The ingestion API is designed made for real-time streaming ingestion and architected for high + * throughput. Even if events are later deemed unnecessary or filtered out, we encourage you to log + * them to Orb if they may be relevant to billing calculations in the future. + * + * To take advantage of the real-time features of the Orb platform and avoid any chance of dropped + * events by producers, we recommend reporting events to Orb frequently. Optionally, events can also + * be briefly aggregated at the source, as this API accepts an array of event bodies. + * + * Orb does not currently enforce a hard rate-limit for API usage or a maximum request payload size, + * but please give us a heads up if you’re changing either of these factors by an order of magnitude + * from initial setup. + * + * ## Testing in debug mode + * + * The ingestion API supports a debug mode, which returns additional verbose output to indicate + * which event idempotency keys were newly ingested or duplicates from previous requests. To enable + * this mode, mark `debug=true` as a query parameter. + * + * If `debug=true` is not specified, the response will only contain `validation_failed`. Orb will + * still honor the idempotency guarantees set + * [here](../guides/events-and-metrics/event-ingestion#event-volume-and-concurrency) in all cases. + * + * We strongly recommend that you only use debug mode as part of testing your initial Orb + * integration. Once you're ready to switch to production, disable debug mode to take advantage of + * improved performance and maximal throughput. + * + * #### Example: ingestion response with `debug=true` + * + * ```json + * { + * "debug": { + * "duplicate": [], + * "ingested": ["B7E83HDMfJPAunXW", "SJs5DQJ3TnwSqEZE", "8SivfDsNKwCeAXim"] + * }, + * "validation_failed": [] + * } + * ``` + * + * #### Example: ingestion response with `debug=false` + * + * ```json + * { + * "validation_failed": [] + * } + * ``` + */ class EventIngestParams constructor( private val backfillId: String?, @@ -37,12 +225,14 @@ constructor( fun events(): List = body.events() + fun _events(): JsonField> = body._events() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): EventIngestBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -60,17 +250,30 @@ constructor( class EventIngestBody @JsonCreator internal constructor( - @JsonProperty("events") private val events: List, + @JsonProperty("events") + @ExcludeMissing + private val events: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("events") fun events(): List = events + fun events(): List = events.getRequired("events") + + @JsonProperty("events") @ExcludeMissing fun _events(): JsonField> = events @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventIngestBody = apply { + if (!validated) { + events().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -80,19 +283,32 @@ constructor( class Builder { - private var events: MutableList? = null + private var events: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(eventIngestBody: EventIngestBody) = apply { - events = eventIngestBody.events.toMutableList() + events = eventIngestBody.events.map { it.toMutableList() } additionalProperties = eventIngestBody.additionalProperties.toMutableMap() } - fun events(events: List) = apply { this.events = events.toMutableList() } + fun events(events: List) = events(JsonField.of(events)) + + fun events(events: JsonField>) = apply { + this.events = events.map { it.toMutableList() } + } fun addEvent(event: Event) = apply { - events = (events ?: mutableListOf()).apply { add(event) } + events = + (events ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(event) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -116,7 +332,8 @@ constructor( fun build(): EventIngestBody = EventIngestBody( - checkNotNull(events) { "`events` is required but was not set" }.toImmutable(), + checkNotNull(events) { "`events` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -188,8 +405,29 @@ constructor( fun events(events: List) = apply { body.events(events) } + fun events(events: JsonField>) = apply { body.events(events) } + fun addEvent(event: Event) = apply { body.addEvent(event) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -288,25 +526,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): EventIngestParams = EventIngestParams( backfillId, @@ -321,51 +540,107 @@ constructor( class Event @JsonCreator private constructor( - @JsonProperty("event_name") private val eventName: String, - @JsonProperty("idempotency_key") private val idempotencyKey: String, - @JsonProperty("properties") private val properties: JsonValue, - @JsonProperty("timestamp") private val timestamp: OffsetDateTime, - @JsonProperty("customer_id") private val customerId: String?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, + @JsonProperty("event_name") + @ExcludeMissing + private val eventName: JsonField = JsonMissing.of(), + @JsonProperty("idempotency_key") + @ExcludeMissing + private val idempotencyKey: JsonField = JsonMissing.of(), + @JsonProperty("properties") + @ExcludeMissing + private val properties: JsonValue = JsonMissing.of(), + @JsonProperty("timestamp") + @ExcludeMissing + private val timestamp: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A name to meaningfully identify the action or event type. */ - @JsonProperty("event_name") fun eventName(): String = eventName + fun eventName(): String = eventName.getRequired("event_name") /** * A unique value, generated by the client, that is used to de-duplicate events. Exactly one * event with a given idempotency key will be ingested, which allows for safe request * retries. */ - @JsonProperty("idempotency_key") fun idempotencyKey(): String = idempotencyKey + fun idempotencyKey(): String = idempotencyKey.getRequired("idempotency_key") /** * A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or * strings. Nested dictionaries are disallowed. */ - @JsonProperty("properties") fun properties(): JsonValue = properties + @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties + + /** + * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the + * time that usage was recorded, and is particularly important to attribute usage to a given + * billing period. + */ + fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp") + + /** The Orb Customer identifier */ + fun customerId(): Optional = + Optional.ofNullable(customerId.getNullable("customer_id")) + + /** An alias for the Orb customer, whose mapping is specified when creating the customer */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** A name to meaningfully identify the action or event type. */ + @JsonProperty("event_name") @ExcludeMissing fun _eventName(): JsonField = eventName + + /** + * A unique value, generated by the client, that is used to de-duplicate events. Exactly one + * event with a given idempotency key will be ingested, which allows for safe request + * retries. + */ + @JsonProperty("idempotency_key") + @ExcludeMissing + fun _idempotencyKey(): JsonField = idempotencyKey /** * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the * time that usage was recorded, and is particularly important to attribute usage to a given * billing period. */ - @JsonProperty("timestamp") fun timestamp(): OffsetDateTime = timestamp + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField = timestamp /** The Orb Customer identifier */ @JsonProperty("customer_id") - fun customerId(): Optional = Optional.ofNullable(customerId) + @ExcludeMissing + fun _customerId(): JsonField = customerId /** An alias for the Orb customer, whose mapping is specified when creating the customer */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Event = apply { + if (!validated) { + eventName() + idempotencyKey() + timestamp() + customerId() + externalCustomerId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -375,12 +650,12 @@ constructor( class Builder { - private var eventName: String? = null - private var idempotencyKey: String? = null + private var eventName: JsonField? = null + private var idempotencyKey: JsonField? = null private var properties: JsonValue? = null - private var timestamp: OffsetDateTime? = null - private var customerId: String? = null - private var externalCustomerId: String? = null + private var timestamp: JsonField? = null + private var customerId: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -395,14 +670,25 @@ constructor( } /** A name to meaningfully identify the action or event type. */ - fun eventName(eventName: String) = apply { this.eventName = eventName } + fun eventName(eventName: String) = eventName(JsonField.of(eventName)) + + /** A name to meaningfully identify the action or event type. */ + fun eventName(eventName: JsonField) = apply { this.eventName = eventName } + + /** + * A unique value, generated by the client, that is used to de-duplicate events. Exactly + * one event with a given idempotency key will be ingested, which allows for safe + * request retries. + */ + fun idempotencyKey(idempotencyKey: String) = + idempotencyKey(JsonField.of(idempotencyKey)) /** * A unique value, generated by the client, that is used to de-duplicate events. Exactly * one event with a given idempotency key will be ingested, which allows for safe * request retries. */ - fun idempotencyKey(idempotencyKey: String) = apply { + fun idempotencyKey(idempotencyKey: JsonField) = apply { this.idempotencyKey = idempotencyKey } @@ -417,20 +703,31 @@ constructor( * time that usage was recorded, and is particularly important to attribute usage to a * given billing period. */ - fun timestamp(timestamp: OffsetDateTime) = apply { this.timestamp = timestamp } + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** + * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the + * time that usage was recorded, and is particularly important to attribute usage to a + * given billing period. + */ + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } /** The Orb Customer identifier */ - fun customerId(customerId: String?) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** The Orb Customer identifier */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** The Orb Customer identifier */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** * An alias for the Orb customer, whose mapping is specified when creating the customer */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * An alias for the Orb customer, whose mapping is specified when creating the customer @@ -438,6 +735,13 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * An alias for the Orb customer, whose mapping is specified when creating the customer + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt index bcf9737a..dea4eb2a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventIngestResponse.kt @@ -44,13 +44,15 @@ private constructor( * Contains all failing validation events. In the case of a 200, this array will always be * empty. This field will always be present. */ - @JsonProperty("validation_failed") @ExcludeMissing fun _validationFailed() = validationFailed + @JsonProperty("validation_failed") + @ExcludeMissing + fun _validationFailed(): JsonField> = validationFailed /** * Optional debug information (only present when debug=true is passed to the endpoint). Contains * ingested and duplicate event idempotency keys. */ - @JsonProperty("debug") @ExcludeMissing fun _debug() = debug + @JsonProperty("debug") @ExcludeMissing fun _debug(): JsonField = debug @JsonAnyGetter @ExcludeMissing @@ -75,13 +77,13 @@ private constructor( class Builder { - private var validationFailed: JsonField> = JsonMissing.of() + private var validationFailed: JsonField>? = null private var debug: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(eventIngestResponse: EventIngestResponse) = apply { - validationFailed = eventIngestResponse.validationFailed + validationFailed = eventIngestResponse.validationFailed.map { it.toMutableList() } debug = eventIngestResponse.debug additionalProperties = eventIngestResponse.additionalProperties.toMutableMap() } @@ -98,14 +100,37 @@ private constructor( * empty. This field will always be present. */ fun validationFailed(validationFailed: JsonField>) = apply { - this.validationFailed = validationFailed + this.validationFailed = validationFailed.map { it.toMutableList() } + } + + /** + * Contains all failing validation events. In the case of a 200, this array will always be + * empty. This field will always be present. + */ + fun addValidationFailed(validationFailed: ValidationFailed) = apply { + this.validationFailed = + (this.validationFailed ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(validationFailed) + } } /** * Optional debug information (only present when debug=true is passed to the endpoint). * Contains ingested and duplicate event idempotency keys. */ - fun debug(debug: Debug) = debug(JsonField.of(debug)) + fun debug(debug: Debug?) = debug(JsonField.ofNullable(debug)) + + /** + * Optional debug information (only present when debug=true is passed to the endpoint). + * Contains ingested and duplicate event idempotency keys. + */ + fun debug(debug: Optional) = debug(debug.orElse(null)) /** * Optional debug information (only present when debug=true is passed to the endpoint). @@ -134,7 +159,8 @@ private constructor( fun build(): EventIngestResponse = EventIngestResponse( - validationFailed.map { it.toImmutable() }, + checkNotNull(validationFailed) { "`validationFailed` is required but was not set" } + .map { it.toImmutable() }, debug, additionalProperties.toImmutable(), ) @@ -161,12 +187,14 @@ private constructor( fun validationErrors(): List = validationErrors.getRequired("validation_errors") /** The passed idempotency_key corresponding to the validation_errors */ - @JsonProperty("idempotency_key") @ExcludeMissing fun _idempotencyKey() = idempotencyKey + @JsonProperty("idempotency_key") + @ExcludeMissing + fun _idempotencyKey(): JsonField = idempotencyKey /** An array of strings corresponding to validation failures for this idempotency_key. */ @JsonProperty("validation_errors") @ExcludeMissing - fun _validationErrors() = validationErrors + fun _validationErrors(): JsonField> = validationErrors @JsonAnyGetter @ExcludeMissing @@ -191,14 +219,14 @@ private constructor( class Builder { - private var idempotencyKey: JsonField = JsonMissing.of() - private var validationErrors: JsonField> = JsonMissing.of() + private var idempotencyKey: JsonField? = null + private var validationErrors: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(validationFailed: ValidationFailed) = apply { idempotencyKey = validationFailed.idempotencyKey - validationErrors = validationFailed.validationErrors + validationErrors = validationFailed.validationErrors.map { it.toMutableList() } additionalProperties = validationFailed.additionalProperties.toMutableMap() } @@ -221,7 +249,23 @@ private constructor( * An array of strings corresponding to validation failures for this idempotency_key. */ fun validationErrors(validationErrors: JsonField>) = apply { - this.validationErrors = validationErrors + this.validationErrors = validationErrors.map { it.toMutableList() } + } + + /** + * An array of strings corresponding to validation failures for this idempotency_key. + */ + fun addValidationError(validationError: String) = apply { + validationErrors = + (validationErrors ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(validationError) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -245,8 +289,11 @@ private constructor( fun build(): ValidationFailed = ValidationFailed( - idempotencyKey, - validationErrors.map { it.toImmutable() }, + checkNotNull(idempotencyKey) { "`idempotencyKey` is required but was not set" }, + checkNotNull(validationErrors) { + "`validationErrors` is required but was not set" + } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -291,9 +338,13 @@ private constructor( fun ingested(): List = ingested.getRequired("ingested") - @JsonProperty("duplicate") @ExcludeMissing fun _duplicate() = duplicate + @JsonProperty("duplicate") + @ExcludeMissing + fun _duplicate(): JsonField> = duplicate - @JsonProperty("ingested") @ExcludeMissing fun _ingested() = ingested + @JsonProperty("ingested") + @ExcludeMissing + fun _ingested(): JsonField> = ingested @JsonAnyGetter @ExcludeMissing @@ -318,24 +369,54 @@ private constructor( class Builder { - private var duplicate: JsonField> = JsonMissing.of() - private var ingested: JsonField> = JsonMissing.of() + private var duplicate: JsonField>? = null + private var ingested: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(debug: Debug) = apply { - duplicate = debug.duplicate - ingested = debug.ingested + duplicate = debug.duplicate.map { it.toMutableList() } + ingested = debug.ingested.map { it.toMutableList() } additionalProperties = debug.additionalProperties.toMutableMap() } fun duplicate(duplicate: List) = duplicate(JsonField.of(duplicate)) - fun duplicate(duplicate: JsonField>) = apply { this.duplicate = duplicate } + fun duplicate(duplicate: JsonField>) = apply { + this.duplicate = duplicate.map { it.toMutableList() } + } + + fun addDuplicate(duplicate: String) = apply { + this.duplicate = + (this.duplicate ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(duplicate) + } + } fun ingested(ingested: List) = ingested(JsonField.of(ingested)) - fun ingested(ingested: JsonField>) = apply { this.ingested = ingested } + fun ingested(ingested: JsonField>) = apply { + this.ingested = ingested.map { it.toMutableList() } + } + + fun addIngested(ingested: String) = apply { + this.ingested = + (this.ingested ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(ingested) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -358,8 +439,10 @@ private constructor( fun build(): Debug = Debug( - duplicate.map { it.toImmutable() }, - ingested.map { it.toImmutable() }, + checkNotNull(duplicate) { "`duplicate` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(ingested) { "`ingested` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt index f2bce686..2b713646 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,20 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * This endpoint returns a filtered set of events for an account in a + * [paginated list format](../reference/pagination). + * + * Note that this is a `POST` endpoint rather than a `GET` endpoint because it employs a JSON body + * for search criteria rather than query parameters, allowing for a more flexible search syntax. + * + * Note that a search criteria _must_ be specified. Currently, Orb supports the following criteria: + * - `event_ids`: This is an explicit array of IDs to filter by. Note that an event's ID is the + * `idempotency_key` that was originally used for ingestion. + * + * By default, Orb will not throw a `404` if no events matched, Orb will return an empty array for + * `data` instead. + */ class EventSearchParams constructor( private val body: EventSearchBody, @@ -43,12 +59,31 @@ constructor( */ fun timeframeStart(): Optional = body.timeframeStart() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * This is an explicit array of IDs to filter by. Note that an event's ID is the idempotency_key + * that was originally used for ingestion, and this only supports events that have not been + * amended. Values in this array will be treated case sensitively. + */ + fun _eventIds(): JsonField> = body._eventIds() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * The end of the timeframe, exclusive, in which to search events. If not specified, the current + * time is used. + */ + fun _timeframeEnd(): JsonField = body._timeframeEnd() + + /** + * The start of the timeframe, inclusive, in which to search events. If not specified, the one + * week ago is used. + */ + fun _timeframeStart(): JsonField = body._timeframeStart() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): EventSearchBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -59,9 +94,15 @@ constructor( class EventSearchBody @JsonCreator internal constructor( - @JsonProperty("event_ids") private val eventIds: List, - @JsonProperty("timeframe_end") private val timeframeEnd: OffsetDateTime?, - @JsonProperty("timeframe_start") private val timeframeStart: OffsetDateTime?, + @JsonProperty("event_ids") + @ExcludeMissing + private val eventIds: JsonField> = JsonMissing.of(), + @JsonProperty("timeframe_end") + @ExcludeMissing + private val timeframeEnd: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_start") + @ExcludeMissing + private val timeframeStart: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -71,26 +112,62 @@ constructor( * idempotency_key that was originally used for ingestion, and this only supports events * that have not been amended. Values in this array will be treated case sensitively. */ - @JsonProperty("event_ids") fun eventIds(): List = eventIds + fun eventIds(): List = eventIds.getRequired("event_ids") + + /** + * The end of the timeframe, exclusive, in which to search events. If not specified, the + * current time is used. + */ + fun timeframeEnd(): Optional = + Optional.ofNullable(timeframeEnd.getNullable("timeframe_end")) + + /** + * The start of the timeframe, inclusive, in which to search events. If not specified, the + * one week ago is used. + */ + fun timeframeStart(): Optional = + Optional.ofNullable(timeframeStart.getNullable("timeframe_start")) + + /** + * This is an explicit array of IDs to filter by. Note that an event's ID is the + * idempotency_key that was originally used for ingestion, and this only supports events + * that have not been amended. Values in this array will be treated case sensitively. + */ + @JsonProperty("event_ids") + @ExcludeMissing + fun _eventIds(): JsonField> = eventIds /** * The end of the timeframe, exclusive, in which to search events. If not specified, the * current time is used. */ @JsonProperty("timeframe_end") - fun timeframeEnd(): Optional = Optional.ofNullable(timeframeEnd) + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd /** * The start of the timeframe, inclusive, in which to search events. If not specified, the * one week ago is used. */ @JsonProperty("timeframe_start") - fun timeframeStart(): Optional = Optional.ofNullable(timeframeStart) + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventSearchBody = apply { + if (!validated) { + eventIds() + timeframeEnd() + timeframeStart() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -100,14 +177,14 @@ constructor( class Builder { - private var eventIds: MutableList? = null - private var timeframeEnd: OffsetDateTime? = null - private var timeframeStart: OffsetDateTime? = null + private var eventIds: JsonField>? = null + private var timeframeEnd: JsonField = JsonMissing.of() + private var timeframeStart: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(eventSearchBody: EventSearchBody) = apply { - eventIds = eventSearchBody.eventIds.toMutableList() + eventIds = eventSearchBody.eventIds.map { it.toMutableList() } timeframeEnd = eventSearchBody.timeframeEnd timeframeStart = eventSearchBody.timeframeStart additionalProperties = eventSearchBody.additionalProperties.toMutableMap() @@ -118,8 +195,15 @@ constructor( * idempotency_key that was originally used for ingestion, and this only supports events * that have not been amended. Values in this array will be treated case sensitively. */ - fun eventIds(eventIds: List) = apply { - this.eventIds = eventIds.toMutableList() + fun eventIds(eventIds: List) = eventIds(JsonField.of(eventIds)) + + /** + * This is an explicit array of IDs to filter by. Note that an event's ID is the + * idempotency_key that was originally used for ingestion, and this only supports events + * that have not been amended. Values in this array will be treated case sensitively. + */ + fun eventIds(eventIds: JsonField>) = apply { + this.eventIds = eventIds.map { it.toMutableList() } } /** @@ -128,16 +212,24 @@ constructor( * that have not been amended. Values in this array will be treated case sensitively. */ fun addEventId(eventId: String) = apply { - eventIds = (eventIds ?: mutableListOf()).apply { add(eventId) } + eventIds = + (eventIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(eventId) + } } /** * The end of the timeframe, exclusive, in which to search events. If not specified, the * current time is used. */ - fun timeframeEnd(timeframeEnd: OffsetDateTime?) = apply { - this.timeframeEnd = timeframeEnd - } + fun timeframeEnd(timeframeEnd: OffsetDateTime?) = + timeframeEnd(JsonField.ofNullable(timeframeEnd)) /** * The end of the timeframe, exclusive, in which to search events. If not specified, the @@ -146,13 +238,20 @@ constructor( fun timeframeEnd(timeframeEnd: Optional) = timeframeEnd(timeframeEnd.orElse(null)) + /** + * The end of the timeframe, exclusive, in which to search events. If not specified, the + * current time is used. + */ + fun timeframeEnd(timeframeEnd: JsonField) = apply { + this.timeframeEnd = timeframeEnd + } + /** * The start of the timeframe, inclusive, in which to search events. If not specified, * the one week ago is used. */ - fun timeframeStart(timeframeStart: OffsetDateTime?) = apply { - this.timeframeStart = timeframeStart - } + fun timeframeStart(timeframeStart: OffsetDateTime?) = + timeframeStart(JsonField.ofNullable(timeframeStart)) /** * The start of the timeframe, inclusive, in which to search events. If not specified, @@ -161,6 +260,14 @@ constructor( fun timeframeStart(timeframeStart: Optional) = timeframeStart(timeframeStart.orElse(null)) + /** + * The start of the timeframe, inclusive, in which to search events. If not specified, + * the one week ago is used. + */ + fun timeframeStart(timeframeStart: JsonField) = apply { + this.timeframeStart = timeframeStart + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -183,7 +290,7 @@ constructor( fun build(): EventSearchBody = EventSearchBody( checkNotNull(eventIds) { "`eventIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, timeframeEnd, timeframeStart, additionalProperties.toImmutable(), @@ -236,6 +343,13 @@ constructor( */ fun eventIds(eventIds: List) = apply { body.eventIds(eventIds) } + /** + * This is an explicit array of IDs to filter by. Note that an event's ID is the + * idempotency_key that was originally used for ingestion, and this only supports events + * that have not been amended. Values in this array will be treated case sensitively. + */ + fun eventIds(eventIds: JsonField>) = apply { body.eventIds(eventIds) } + /** * This is an explicit array of IDs to filter by. Note that an event's ID is the * idempotency_key that was originally used for ingestion, and this only supports events @@ -256,6 +370,14 @@ constructor( fun timeframeEnd(timeframeEnd: Optional) = timeframeEnd(timeframeEnd.orElse(null)) + /** + * The end of the timeframe, exclusive, in which to search events. If not specified, the + * current time is used. + */ + fun timeframeEnd(timeframeEnd: JsonField) = apply { + body.timeframeEnd(timeframeEnd) + } + /** * The start of the timeframe, inclusive, in which to search events. If not specified, the * one week ago is used. @@ -271,6 +393,33 @@ constructor( fun timeframeStart(timeframeStart: Optional) = timeframeStart(timeframeStart.orElse(null)) + /** + * The start of the timeframe, inclusive, in which to search events. If not specified, the + * one week ago is used. + */ + fun timeframeStart(timeframeStart: JsonField) = apply { + body.timeframeStart(timeframeStart) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -369,25 +518,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): EventSearchParams = EventSearchParams( body.build(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt index 113b29b2..8eaf8bcd 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventSearchResponse.kt @@ -29,7 +29,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -53,18 +53,33 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(eventSearchResponse: EventSearchResponse) = apply { - data = eventSearchResponse.data + data = eventSearchResponse.data.map { it.toMutableList() } additionalProperties = eventSearchResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -86,7 +101,11 @@ private constructor( } fun build(): EventSearchResponse = - EventSearchResponse(data.map { it.toImmutable() }, additionalProperties.toImmutable()) + EventSearchResponse( + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } /** @@ -142,6 +161,12 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + /** + * A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or + * strings. Nested dictionaries are disallowed. + */ + @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties + /** * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the * time that usage was recorded, and is particularly important to attribute usage to a given @@ -154,34 +179,34 @@ private constructor( * event with a given idempotency key will be ingested, which allows for safe request * retries. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The Orb Customer identifier */ - @JsonProperty("customer_id") @ExcludeMissing fun _customerId() = customerId + @JsonProperty("customer_id") + @ExcludeMissing + fun _customerId(): JsonField = customerId /** A boolean indicating whether the event is currently deprecated. */ - @JsonProperty("deprecated") @ExcludeMissing fun _deprecated() = deprecated + @JsonProperty("deprecated") + @ExcludeMissing + fun _deprecated(): JsonField = deprecated /** A name to meaningfully identify the action or event type. */ - @JsonProperty("event_name") @ExcludeMissing fun _eventName() = eventName + @JsonProperty("event_name") @ExcludeMissing fun _eventName(): JsonField = eventName /** An alias for the Orb customer, whose mapping is specified when creating the customer */ @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId - - /** - * A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or - * strings. Nested dictionaries are disallowed. - */ - @JsonProperty("properties") @ExcludeMissing fun _properties() = properties + fun _externalCustomerId(): JsonField = externalCustomerId /** * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the * time that usage was recorded, and is particularly important to attribute usage to a given * billing period. */ - @JsonProperty("timestamp") @ExcludeMissing fun _timestamp() = timestamp + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField = timestamp @JsonAnyGetter @ExcludeMissing @@ -210,13 +235,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var customerId: JsonField = JsonMissing.of() - private var deprecated: JsonField = JsonMissing.of() - private var eventName: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() - private var properties: JsonValue = JsonMissing.of() - private var timestamp: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var customerId: JsonField? = null + private var deprecated: JsonField? = null + private var eventName: JsonField? = null + private var externalCustomerId: JsonField? = null + private var properties: JsonValue? = null + private var timestamp: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -246,7 +271,10 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } /** The Orb Customer identifier */ - fun customerId(customerId: String) = customerId(JsonField.of(customerId)) + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) + + /** The Orb Customer identifier */ + fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) /** The Orb Customer identifier */ fun customerId(customerId: JsonField) = apply { this.customerId = customerId } @@ -266,8 +294,14 @@ private constructor( /** * An alias for the Orb customer, whose mapping is specified when creating the customer */ - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + /** + * An alias for the Orb customer, whose mapping is specified when creating the customer + */ + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) /** * An alias for the Orb customer, whose mapping is specified when creating the customer @@ -319,13 +353,15 @@ private constructor( fun build(): Data = Data( - id, - customerId, - deprecated, - eventName, - externalCustomerId, - properties, - timestamp, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(customerId) { "`customerId` is required but was not set" }, + checkNotNull(deprecated) { "`deprecated` is required but was not set" }, + checkNotNull(eventName) { "`eventName` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, + checkNotNull(properties) { "`properties` is required but was not set" }, + checkNotNull(timestamp) { "`timestamp` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt index 7d877ef2..7e146df1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,45 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * This endpoint is used to amend a single usage event with a given `event_id`. `event_id` refers to + * the `idempotency_key` passed in during ingestion. The event will maintain its existing `event_id` + * after the amendment. + * + * This endpoint will mark the existing event as ignored, and Orb will only use the new event passed + * in the body of this request as the source of truth for that `event_id`. Note that a single event + * can be amended any number of times, so the same event can be overwritten in subsequent calls to + * this endpoint. Only a single event with a given `event_id` will be considered the source of truth + * at any given time. + * + * This is a powerful and audit-safe mechanism to retroactively update a single event in cases where + * you need to: + * - update an event with new metadata as you iterate on your pricing model + * - update an event based on the result of an external API call (e.g. call to a payment gateway + * succeeded or failed) + * + * This amendment API is always audit-safe. The process will still retain the original event, though + * it will be ignored for billing calculations. For auditing and data fidelity purposes, Orb never + * overwrites or permanently deletes ingested usage data. + * + * ## Request validation + * - The `timestamp` of the new event must match the `timestamp` of the existing event already + * ingested. As with ingestion, all timestamps must be sent in ISO8601 format with UTC timezone + * offset. + * - The `customer_id` or `external_customer_id` of the new event must match the `customer_id` or + * `external_customer_id` of the existing event already ingested. Exactly one of `customer_id` and + * `external_customer_id` should be specified, and similar to ingestion, the ID must identify a + * Customer resource within Orb. Unlike ingestion, for event amendment, we strictly enforce that + * the Customer must be in the Orb system, even during the initial integration period. We do not + * allow updating the `Customer` an event is associated with. + * - Orb does not accept an `idempotency_key` with the event in this endpoint, since this request is + * by design idempotent. On retryable errors, you should retry the request and assume the + * amendment operation has not succeeded until receipt of a 2xx. + * - The event's `timestamp` must fall within the customer's current subscription's billing period, + * or within the grace period of the customer's current subscription's previous billing period. + * - By default, no more than 100 events can be amended for a single customer in a 100 day period. + * For higher volume updates, consider using the [event backfill](create-backfill) endpoint. + */ class EventUpdateParams constructor( private val eventId: String, @@ -34,7 +75,7 @@ constructor( * A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or * strings. Nested dictionaries are disallowed. */ - fun properties(): JsonValue = body.properties() + fun _properties(): JsonValue = body._properties() /** * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the time @@ -49,12 +90,28 @@ constructor( /** An alias for the Orb customer, whose mapping is specified when creating the customer */ fun externalCustomerId(): Optional = body.externalCustomerId() - fun _additionalHeaders(): Headers = additionalHeaders + /** A name to meaningfully identify the action or event type. */ + fun _eventName(): JsonField = body._eventName() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the time + * that usage was recorded, and is particularly important to attribute usage to a given billing + * period. + */ + fun _timestamp(): JsonField = body._timestamp() + + /** The Orb Customer identifier */ + fun _customerId(): JsonField = body._customerId() + + /** An alias for the Orb customer, whose mapping is specified when creating the customer */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): EventUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -72,43 +129,87 @@ constructor( class EventUpdateBody @JsonCreator internal constructor( - @JsonProperty("event_name") private val eventName: String, - @JsonProperty("properties") private val properties: JsonValue, - @JsonProperty("timestamp") private val timestamp: OffsetDateTime, - @JsonProperty("customer_id") private val customerId: String?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, + @JsonProperty("event_name") + @ExcludeMissing + private val eventName: JsonField = JsonMissing.of(), + @JsonProperty("properties") + @ExcludeMissing + private val properties: JsonValue = JsonMissing.of(), + @JsonProperty("timestamp") + @ExcludeMissing + private val timestamp: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A name to meaningfully identify the action or event type. */ - @JsonProperty("event_name") fun eventName(): String = eventName + fun eventName(): String = eventName.getRequired("event_name") /** * A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or * strings. Nested dictionaries are disallowed. */ - @JsonProperty("properties") fun properties(): JsonValue = properties + @JsonProperty("properties") @ExcludeMissing fun _properties(): JsonValue = properties /** * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the * time that usage was recorded, and is particularly important to attribute usage to a given * billing period. */ - @JsonProperty("timestamp") fun timestamp(): OffsetDateTime = timestamp + fun timestamp(): OffsetDateTime = timestamp.getRequired("timestamp") + + /** The Orb Customer identifier */ + fun customerId(): Optional = + Optional.ofNullable(customerId.getNullable("customer_id")) + + /** An alias for the Orb customer, whose mapping is specified when creating the customer */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** A name to meaningfully identify the action or event type. */ + @JsonProperty("event_name") @ExcludeMissing fun _eventName(): JsonField = eventName + + /** + * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the + * time that usage was recorded, and is particularly important to attribute usage to a given + * billing period. + */ + @JsonProperty("timestamp") + @ExcludeMissing + fun _timestamp(): JsonField = timestamp /** The Orb Customer identifier */ @JsonProperty("customer_id") - fun customerId(): Optional = Optional.ofNullable(customerId) + @ExcludeMissing + fun _customerId(): JsonField = customerId /** An alias for the Orb customer, whose mapping is specified when creating the customer */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EventUpdateBody = apply { + if (!validated) { + eventName() + timestamp() + customerId() + externalCustomerId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -118,11 +219,11 @@ constructor( class Builder { - private var eventName: String? = null + private var eventName: JsonField? = null private var properties: JsonValue? = null - private var timestamp: OffsetDateTime? = null - private var customerId: String? = null - private var externalCustomerId: String? = null + private var timestamp: JsonField? = null + private var customerId: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -136,7 +237,10 @@ constructor( } /** A name to meaningfully identify the action or event type. */ - fun eventName(eventName: String) = apply { this.eventName = eventName } + fun eventName(eventName: String) = eventName(JsonField.of(eventName)) + + /** A name to meaningfully identify the action or event type. */ + fun eventName(eventName: JsonField) = apply { this.eventName = eventName } /** * A dictionary of custom properties. Values in this dictionary must be numeric, @@ -149,20 +253,31 @@ constructor( * time that usage was recorded, and is particularly important to attribute usage to a * given billing period. */ - fun timestamp(timestamp: OffsetDateTime) = apply { this.timestamp = timestamp } + fun timestamp(timestamp: OffsetDateTime) = timestamp(JsonField.of(timestamp)) + + /** + * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the + * time that usage was recorded, and is particularly important to attribute usage to a + * given billing period. + */ + fun timestamp(timestamp: JsonField) = apply { + this.timestamp = timestamp + } /** The Orb Customer identifier */ - fun customerId(customerId: String?) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** The Orb Customer identifier */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** The Orb Customer identifier */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** * An alias for the Orb customer, whose mapping is specified when creating the customer */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * An alias for the Orb customer, whose mapping is specified when creating the customer @@ -170,6 +285,13 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * An alias for the Orb customer, whose mapping is specified when creating the customer + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -246,6 +368,9 @@ constructor( /** A name to meaningfully identify the action or event type. */ fun eventName(eventName: String) = apply { body.eventName(eventName) } + /** A name to meaningfully identify the action or event type. */ + fun eventName(eventName: JsonField) = apply { body.eventName(eventName) } + /** * A dictionary of custom properties. Values in this dictionary must be numeric, boolean, or * strings. Nested dictionaries are disallowed. @@ -259,12 +384,22 @@ constructor( */ fun timestamp(timestamp: OffsetDateTime) = apply { body.timestamp(timestamp) } + /** + * An ISO 8601 format date with no timezone offset (i.e. UTC). This should represent the + * time that usage was recorded, and is particularly important to attribute usage to a given + * billing period. + */ + fun timestamp(timestamp: JsonField) = apply { body.timestamp(timestamp) } + /** The Orb Customer identifier */ fun customerId(customerId: String?) = apply { body.customerId(customerId) } /** The Orb Customer identifier */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** The Orb Customer identifier */ + fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + /** An alias for the Orb customer, whose mapping is specified when creating the customer */ fun externalCustomerId(externalCustomerId: String?) = apply { body.externalCustomerId(externalCustomerId) @@ -274,6 +409,30 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** An alias for the Orb customer, whose mapping is specified when creating the customer */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -372,25 +531,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): EventUpdateParams = EventUpdateParams( checkNotNull(eventId) { "`eventId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt index 3d3e7c94..9f3602f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventUpdateResponse.kt @@ -29,7 +29,7 @@ private constructor( fun amended(): String = amended.getRequired("amended") /** event_id of the amended event, if successfully ingested */ - @JsonProperty("amended") @ExcludeMissing fun _amended() = amended + @JsonProperty("amended") @ExcludeMissing fun _amended(): JsonField = amended @JsonAnyGetter @ExcludeMissing @@ -53,7 +53,7 @@ private constructor( class Builder { - private var amended: JsonField = JsonMissing.of() + private var amended: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -88,7 +88,10 @@ private constructor( } fun build(): EventUpdateResponse = - EventUpdateResponse(amended, additionalProperties.toImmutable()) + EventUpdateResponse( + checkNotNull(amended) { "`amended` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt index 69ad89ee..794fce9d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumeListParams.kt @@ -10,6 +10,19 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns the event volume for an account in a + * [paginated list format](../reference/pagination). + * + * The event volume is aggregated by the hour and the + * [timestamp](../reference/ingest#determining-event-timestamp) field is used to determine which + * hour an event is associated with. Note, this means that late-arriving events increment the volume + * count for the hour window the timestamp is in, not the latest hour window. + * + * Each item in the response contains the count of events aggregated by the hour where the start and + * end time are hour-aligned and in UTC. When a specific timestamp is passed in for either start or + * end time, the response includes the hours the timestamp falls in. + */ class EventVolumeListParams constructor( private val timeframeStart: OffsetDateTime, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt index 63840b32..e16e11bc 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/EventVolumes.kt @@ -28,7 +28,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -52,18 +52,33 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(eventVolumes: EventVolumes) = apply { - data = eventVolumes.data + data = eventVolumes.data.map { it.toMutableList() } additionalProperties = eventVolumes.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -85,7 +100,11 @@ private constructor( } fun build(): EventVolumes = - EventVolumes(data.map { it.toImmutable() }, additionalProperties.toImmutable()) + EventVolumes( + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } /** @@ -117,11 +136,15 @@ private constructor( fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") /** The number of events ingested with a timestamp between the timeframe */ - @JsonProperty("count") @ExcludeMissing fun _count() = count + @JsonProperty("count") @ExcludeMissing fun _count(): JsonField = count - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart @JsonAnyGetter @ExcludeMissing @@ -147,9 +170,9 @@ private constructor( class Builder { - private var count: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var count: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -201,9 +224,9 @@ private constructor( fun build(): Data = Data( - count, - timeframeEnd, - timeframeStart, + checkNotNull(count) { "`count` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt index 08fee8df..3ed0c90d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Invoice.kt @@ -296,6 +296,12 @@ private constructor( fun customerTaxId(): Optional = Optional.ofNullable(customerTaxId.getNullable("customer_tax_id")) + /** + * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the + * first discount in the list will be returned. If the list is empty, `None` will be returned. + */ + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonValue = discount + fun discounts(): List = discounts.getRequired("discounts") /** When the invoice payment is due. */ @@ -427,32 +433,41 @@ private constructor( */ fun willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * This is the final amount required to be charged to the customer and reflects the application * of the customer balance to the `total` of the invoice. */ - @JsonProperty("amount_due") @ExcludeMissing fun _amountDue() = amountDue + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection - @JsonProperty("billing_address") @ExcludeMissing fun _billingAddress() = billingAddress + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress /** The creation time of the resource in Orb. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** A list of credit notes associated with the invoice */ - @JsonProperty("credit_notes") @ExcludeMissing fun _creditNotes() = creditNotes + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes /** An ISO 4217 currency string or `credits` */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer @JsonProperty("customer_balance_transactions") @ExcludeMissing - fun _customerBalanceTransactions() = customerBalanceTransactions + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to the @@ -560,18 +575,16 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("customer_tax_id") @ExcludeMissing fun _customerTaxId() = customerTaxId - - /** - * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the - * first discount in the list will be returned. If the list is empty, `None` will be returned. - */ - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId - @JsonProperty("discounts") @ExcludeMissing fun _discounts() = discounts + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** When the invoice payment is due. */ - @JsonProperty("due_date") @ExcludeMissing fun _dueDate() = dueDate + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate /** * If the invoice has a status of `draft`, this will be the time that the invoice will be @@ -580,113 +593,145 @@ private constructor( */ @JsonProperty("eligible_to_issue_at") @ExcludeMissing - fun _eligibleToIssueAt() = eligibleToIssueAt + fun _eligibleToIssueAt(): JsonField = eligibleToIssueAt /** * A URL for the customer-facing invoice portal. This URL expires 30 days after the invoice's * due date, or 60 days after being re-generated through the UI. */ - @JsonProperty("hosted_invoice_url") @ExcludeMissing fun _hostedInvoiceUrl() = hostedInvoiceUrl + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl /** The scheduled date of the invoice */ - @JsonProperty("invoice_date") @ExcludeMissing fun _invoiceDate() = invoiceDate + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate /** * Automatically generated invoice number to help track and reconcile invoices. Invoice numbers * have a prefix such as `RFOBWG`. These can be sequential per account or customer. */ - @JsonProperty("invoice_number") @ExcludeMissing fun _invoiceNumber() = invoiceNumber + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber /** The link to download the PDF representation of the `Invoice`. */ - @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf() = invoicePdf + @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf(): JsonField = invoicePdf - @JsonProperty("invoice_source") @ExcludeMissing fun _invoiceSource() = invoiceSource + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = invoiceSource /** * If the invoice failed to issue, this will be the last time it failed to issue (even if it is * now in a different state.) */ - @JsonProperty("issue_failed_at") @ExcludeMissing fun _issueFailedAt() = issueFailedAt + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = issueFailedAt /** * If the invoice has been issued, this will be the time it transitioned to `issued` (even if it * is now in a different state.) */ - @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt() = issuedAt + @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt(): JsonField = issuedAt /** The breakdown of prices in this invoice. */ - @JsonProperty("line_items") @ExcludeMissing fun _lineItems() = lineItems + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. */ - @JsonProperty("paid_at") @ExcludeMissing fun _paidAt() = paidAt + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt /** A list of payment attempts associated with the invoice */ - @JsonProperty("payment_attempts") @ExcludeMissing fun _paymentAttempts() = paymentAttempts + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts /** * If payment was attempted on this invoice but failed, this will be the time of the most recent * attempt. */ - @JsonProperty("payment_failed_at") @ExcludeMissing fun _paymentFailedAt() = paymentFailedAt + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = paymentFailedAt /** * If payment was attempted on this invoice, this will be the start time of the most recent * attempt. This field is especially useful for delayed-notification payment mechanisms (like * bank transfers), where payment can take 3 days or more. */ - @JsonProperty("payment_started_at") @ExcludeMissing fun _paymentStartedAt() = paymentStartedAt + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt /** * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be * issued. */ - @JsonProperty("scheduled_issue_at") @ExcludeMissing fun _scheduledIssueAt() = scheduledIssueAt + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt - @JsonProperty("shipping_address") @ExcludeMissing fun _shippingAddress() = shippingAddress + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("subscription") @ExcludeMissing fun _subscription() = subscription + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription /** The total before any discounts and minimums are applied. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** * If the invoice failed to sync, this will be the last time an external invoicing provider sync * was attempted. This field will always be `null` for invoices using Orb Invoicing. */ - @JsonProperty("sync_failed_at") @ExcludeMissing fun _syncFailedAt() = syncFailedAt + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt /** The total after any minimums and discounts have been applied. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total /** * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. */ - @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt() = voidedAt + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt /** * This is true if the invoice will be automatically issued in the future, and false otherwise. */ - @JsonProperty("will_auto_issue") @ExcludeMissing fun _willAutoIssue() = willAutoIssue + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue @JsonAnyGetter @ExcludeMissing @@ -749,48 +794,49 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amountDue: JsonField = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingAddress: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNotes: JsonField> = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var customerBalanceTransactions: JsonField> = - JsonMissing.of() - private var customerTaxId: JsonField = JsonMissing.of() - private var discount: JsonValue = JsonMissing.of() - private var discounts: JsonField> = JsonMissing.of() - private var dueDate: JsonField = JsonMissing.of() - private var eligibleToIssueAt: JsonField = JsonMissing.of() - private var hostedInvoiceUrl: JsonField = JsonMissing.of() - private var invoiceDate: JsonField = JsonMissing.of() - private var invoiceNumber: JsonField = JsonMissing.of() - private var invoicePdf: JsonField = JsonMissing.of() - private var invoiceSource: JsonField = JsonMissing.of() - private var issueFailedAt: JsonField = JsonMissing.of() - private var issuedAt: JsonField = JsonMissing.of() - private var lineItems: JsonField> = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var paidAt: JsonField = JsonMissing.of() - private var paymentAttempts: JsonField> = JsonMissing.of() - private var paymentFailedAt: JsonField = JsonMissing.of() - private var paymentStartedAt: JsonField = JsonMissing.of() - private var scheduledIssueAt: JsonField = JsonMissing.of() - private var shippingAddress: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var subscription: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var syncFailedAt: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() - private var voidedAt: JsonField = JsonMissing.of() - private var willAutoIssue: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amountDue: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField? = null + private var createdAt: JsonField? = null + private var creditNotes: JsonField>? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var customerBalanceTransactions: + JsonField>? = + null + private var customerTaxId: JsonField? = null + private var discount: JsonValue? = null + private var discounts: JsonField>? = null + private var dueDate: JsonField? = null + private var eligibleToIssueAt: JsonField? = null + private var hostedInvoiceUrl: JsonField? = null + private var invoiceDate: JsonField? = null + private var invoiceNumber: JsonField? = null + private var invoicePdf: JsonField? = null + private var invoiceSource: JsonField? = null + private var issueFailedAt: JsonField? = null + private var issuedAt: JsonField? = null + private var lineItems: JsonField>? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var memo: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var paidAt: JsonField? = null + private var paymentAttempts: JsonField>? = null + private var paymentFailedAt: JsonField? = null + private var paymentStartedAt: JsonField? = null + private var scheduledIssueAt: JsonField? = null + private var shippingAddress: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var subtotal: JsonField? = null + private var syncFailedAt: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -800,13 +846,14 @@ private constructor( autoCollection = invoice.autoCollection billingAddress = invoice.billingAddress createdAt = invoice.createdAt - creditNotes = invoice.creditNotes + creditNotes = invoice.creditNotes.map { it.toMutableList() } currency = invoice.currency customer = invoice.customer - customerBalanceTransactions = invoice.customerBalanceTransactions + customerBalanceTransactions = + invoice.customerBalanceTransactions.map { it.toMutableList() } customerTaxId = invoice.customerTaxId discount = invoice.discount - discounts = invoice.discounts + discounts = invoice.discounts.map { it.toMutableList() } dueDate = invoice.dueDate eligibleToIssueAt = invoice.eligibleToIssueAt hostedInvoiceUrl = invoice.hostedInvoiceUrl @@ -816,7 +863,7 @@ private constructor( invoiceSource = invoice.invoiceSource issueFailedAt = invoice.issueFailedAt issuedAt = invoice.issuedAt - lineItems = invoice.lineItems + lineItems = invoice.lineItems.map { it.toMutableList() } maximum = invoice.maximum maximumAmount = invoice.maximumAmount memo = invoice.memo @@ -824,7 +871,7 @@ private constructor( minimum = invoice.minimum minimumAmount = invoice.minimumAmount paidAt = invoice.paidAt - paymentAttempts = invoice.paymentAttempts + paymentAttempts = invoice.paymentAttempts.map { it.toMutableList() } paymentFailedAt = invoice.paymentFailedAt paymentStartedAt = invoice.paymentStartedAt scheduledIssueAt = invoice.scheduledIssueAt @@ -862,8 +909,11 @@ private constructor( this.autoCollection = autoCollection } - fun billingAddress(billingAddress: BillingAddress) = - billingAddress(JsonField.of(billingAddress)) + fun billingAddress(billingAddress: BillingAddress?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.orElse(null)) fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress @@ -880,7 +930,21 @@ private constructor( /** A list of credit notes associated with the invoice */ fun creditNotes(creditNotes: JsonField>) = apply { - this.creditNotes = creditNotes + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** A list of credit notes associated with the invoice */ + fun addCreditNote(creditNote: CreditNote) = apply { + creditNotes = + (creditNotes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(creditNote) + } } /** An ISO 4217 currency string or `credits` */ @@ -899,7 +963,24 @@ private constructor( fun customerBalanceTransactions( customerBalanceTransactions: JsonField> - ) = apply { this.customerBalanceTransactions = customerBalanceTransactions } + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = + apply { + customerBalanceTransactions = + (customerBalanceTransactions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(customerBalanceTransaction) + } + } /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1007,7 +1088,117 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: CustomerTaxId) = customerTaxId(JsonField.of(customerTaxId)) + fun customerTaxId(customerTaxId: CustomerTaxId?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1129,7 +1320,20 @@ private constructor( fun discounts(discounts: List) = discounts(JsonField.of(discounts)) fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts + this.discounts = discounts.map { it.toMutableList() } + } + + fun addDiscount(discount: InvoiceLevelDiscount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** When the invoice payment is due. */ @@ -1143,8 +1347,16 @@ private constructor( * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice * will automatically begin issuing at this time. */ - fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime) = - eligibleToIssueAt(JsonField.of(eligibleToIssueAt)) + fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime?) = + eligibleToIssueAt(JsonField.ofNullable(eligibleToIssueAt)) + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice + * will automatically begin issuing at this time. + */ + fun eligibleToIssueAt(eligibleToIssueAt: Optional) = + eligibleToIssueAt(eligibleToIssueAt.orElse(null)) /** * If the invoice has a status of `draft`, this will be the time that the invoice will be @@ -1159,8 +1371,15 @@ private constructor( * A URL for the customer-facing invoice portal. This URL expires 30 days after the * invoice's due date, or 60 days after being re-generated through the UI. */ - fun hostedInvoiceUrl(hostedInvoiceUrl: String) = - hostedInvoiceUrl(JsonField.of(hostedInvoiceUrl)) + fun hostedInvoiceUrl(hostedInvoiceUrl: String?) = + hostedInvoiceUrl(JsonField.ofNullable(hostedInvoiceUrl)) + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: Optional) = + hostedInvoiceUrl(hostedInvoiceUrl.orElse(null)) /** * A URL for the customer-facing invoice portal. This URL expires 30 days after the @@ -1193,7 +1412,10 @@ private constructor( } /** The link to download the PDF representation of the `Invoice`. */ - fun invoicePdf(invoicePdf: String) = invoicePdf(JsonField.of(invoicePdf)) + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: Optional) = invoicePdf(invoicePdf.orElse(null)) /** The link to download the PDF representation of the `Invoice`. */ fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } @@ -1208,8 +1430,15 @@ private constructor( * If the invoice failed to issue, this will be the last time it failed to issue (even if it * is now in a different state.) */ - fun issueFailedAt(issueFailedAt: OffsetDateTime) = - issueFailedAt(JsonField.of(issueFailedAt)) + fun issueFailedAt(issueFailedAt: OffsetDateTime?) = + issueFailedAt(JsonField.ofNullable(issueFailedAt)) + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it + * is now in a different state.) + */ + fun issueFailedAt(issueFailedAt: Optional) = + issueFailedAt(issueFailedAt.orElse(null)) /** * If the invoice failed to issue, this will be the last time it failed to issue (even if it @@ -1223,7 +1452,13 @@ private constructor( * If the invoice has been issued, this will be the time it transitioned to `issued` (even * if it is now in a different state.) */ - fun issuedAt(issuedAt: OffsetDateTime) = issuedAt(JsonField.of(issuedAt)) + fun issuedAt(issuedAt: OffsetDateTime?) = issuedAt(JsonField.ofNullable(issuedAt)) + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even + * if it is now in a different state.) + */ + fun issuedAt(issuedAt: Optional) = issuedAt(issuedAt.orElse(null)) /** * If the invoice has been issued, this will be the time it transitioned to `issued` (even @@ -1235,20 +1470,45 @@ private constructor( fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) /** The breakdown of prices in this invoice. */ - fun lineItems(lineItems: JsonField>) = apply { this.lineItems = lineItems } + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } + } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + /** The breakdown of prices in this invoice. */ + fun addLineItem(lineItem: LineItem) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(lineItem) + } + } + + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount } /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -1267,11 +1527,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -1280,7 +1546,12 @@ private constructor( /** * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. */ - fun paidAt(paidAt: OffsetDateTime) = paidAt(JsonField.of(paidAt)) + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: Optional) = paidAt(paidAt.orElse(null)) /** * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. @@ -1293,15 +1564,36 @@ private constructor( /** A list of payment attempts associated with the invoice */ fun paymentAttempts(paymentAttempts: JsonField>) = apply { - this.paymentAttempts = paymentAttempts + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** A list of payment attempts associated with the invoice */ + fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + paymentAttempts = + (paymentAttempts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(paymentAttempt) + } } /** * If payment was attempted on this invoice but failed, this will be the time of the most * recent attempt. */ - fun paymentFailedAt(paymentFailedAt: OffsetDateTime) = - paymentFailedAt(JsonField.of(paymentFailedAt)) + fun paymentFailedAt(paymentFailedAt: OffsetDateTime?) = + paymentFailedAt(JsonField.ofNullable(paymentFailedAt)) + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + */ + fun paymentFailedAt(paymentFailedAt: Optional) = + paymentFailedAt(paymentFailedAt.orElse(null)) /** * If payment was attempted on this invoice but failed, this will be the time of the most @@ -1316,8 +1608,16 @@ private constructor( * attempt. This field is especially useful for delayed-notification payment mechanisms * (like bank transfers), where payment can take 3 days or more. */ - fun paymentStartedAt(paymentStartedAt: OffsetDateTime) = - paymentStartedAt(JsonField.of(paymentStartedAt)) + fun paymentStartedAt(paymentStartedAt: OffsetDateTime?) = + paymentStartedAt(JsonField.ofNullable(paymentStartedAt)) + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms + * (like bank transfers), where payment can take 3 days or more. + */ + fun paymentStartedAt(paymentStartedAt: Optional) = + paymentStartedAt(paymentStartedAt.orElse(null)) /** * If payment was attempted on this invoice, this will be the start time of the most recent @@ -1332,8 +1632,15 @@ private constructor( * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to * be issued. */ - fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime) = - scheduledIssueAt(JsonField.of(scheduledIssueAt)) + fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime?) = + scheduledIssueAt(JsonField.ofNullable(scheduledIssueAt)) + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: Optional) = + scheduledIssueAt(scheduledIssueAt.orElse(null)) /** * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to @@ -1343,8 +1650,11 @@ private constructor( this.scheduledIssueAt = scheduledIssueAt } - fun shippingAddress(shippingAddress: ShippingAddress) = - shippingAddress(JsonField.of(shippingAddress)) + fun shippingAddress(shippingAddress: ShippingAddress?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress @@ -1354,7 +1664,11 @@ private constructor( fun status(status: JsonField) = apply { this.status = status } - fun subscription(subscription: Subscription) = subscription(JsonField.of(subscription)) + fun subscription(subscription: Subscription?) = + subscription(JsonField.ofNullable(subscription)) + + fun subscription(subscription: Optional) = + subscription(subscription.orElse(null)) fun subscription(subscription: JsonField) = apply { this.subscription = subscription @@ -1370,7 +1684,15 @@ private constructor( * If the invoice failed to sync, this will be the last time an external invoicing provider * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. */ - fun syncFailedAt(syncFailedAt: OffsetDateTime) = syncFailedAt(JsonField.of(syncFailedAt)) + fun syncFailedAt(syncFailedAt: OffsetDateTime?) = + syncFailedAt(JsonField.ofNullable(syncFailedAt)) + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider + * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + fun syncFailedAt(syncFailedAt: Optional) = + syncFailedAt(syncFailedAt.orElse(null)) /** * If the invoice failed to sync, this will be the last time an external invoicing provider @@ -1390,7 +1712,13 @@ private constructor( * If the invoice has a status of `void`, this gives a timestamp when the invoice was * voided. */ - fun voidedAt(voidedAt: OffsetDateTime) = voidedAt(JsonField.of(voidedAt)) + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) /** * If the invoice has a status of `void`, this gives a timestamp when the invoice was @@ -1433,47 +1761,56 @@ private constructor( fun build(): Invoice = Invoice( - id, - amountDue, - autoCollection, - billingAddress, - createdAt, - creditNotes.map { it.toImmutable() }, - currency, - customer, - customerBalanceTransactions.map { it.toImmutable() }, - customerTaxId, - discount, - discounts.map { it.toImmutable() }, - dueDate, - eligibleToIssueAt, - hostedInvoiceUrl, - invoiceDate, - invoiceNumber, - invoicePdf, - invoiceSource, - issueFailedAt, - issuedAt, - lineItems.map { it.toImmutable() }, - maximum, - maximumAmount, - memo, - metadata, - minimum, - minimumAmount, - paidAt, - paymentAttempts.map { it.toImmutable() }, - paymentFailedAt, - paymentStartedAt, - scheduledIssueAt, - shippingAddress, - status, - subscription, - subtotal, - syncFailedAt, - total, - voidedAt, - willAutoIssue, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amountDue) { "`amountDue` is required but was not set" }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingAddress) { "`billingAddress` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNotes) { "`creditNotes` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(customerBalanceTransactions) { + "`customerBalanceTransactions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(customerTaxId) { "`customerTaxId` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(discounts) { "`discounts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(dueDate) { "`dueDate` is required but was not set" }, + checkNotNull(eligibleToIssueAt) { + "`eligibleToIssueAt` is required but was not set" + }, + checkNotNull(hostedInvoiceUrl) { "`hostedInvoiceUrl` is required but was not set" }, + checkNotNull(invoiceDate) { "`invoiceDate` is required but was not set" }, + checkNotNull(invoiceNumber) { "`invoiceNumber` is required but was not set" }, + checkNotNull(invoicePdf) { "`invoicePdf` is required but was not set" }, + checkNotNull(invoiceSource) { "`invoiceSource` is required but was not set" }, + checkNotNull(issueFailedAt) { "`issueFailedAt` is required but was not set" }, + checkNotNull(issuedAt) { "`issuedAt` is required but was not set" }, + checkNotNull(lineItems) { "`lineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(paidAt) { "`paidAt` is required but was not set" }, + checkNotNull(paymentAttempts) { "`paymentAttempts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(paymentFailedAt) { "`paymentFailedAt` is required but was not set" }, + checkNotNull(paymentStartedAt) { "`paymentStartedAt` is required but was not set" }, + checkNotNull(scheduledIssueAt) { "`scheduledIssueAt` is required but was not set" }, + checkNotNull(shippingAddress) { "`shippingAddress` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(subscription) { "`subscription` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(syncFailedAt) { "`syncFailedAt` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, + checkNotNull(voidedAt) { "`voidedAt` is required but was not set" }, + checkNotNull(willAutoIssue) { "`willAutoIssue` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1525,17 +1862,21 @@ private constructor( Optional.ofNullable(previouslyAttemptedAt.getNullable("previously_attempted_at")) /** True only if auto-collection is enabled for this invoice. */ - @JsonProperty("enabled") @ExcludeMissing fun _enabled() = enabled + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled /** * If the invoice is scheduled for auto-collection, this field will reflect when the next * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for * this invoice, this field will be `null`. */ - @JsonProperty("next_attempt_at") @ExcludeMissing fun _nextAttemptAt() = nextAttemptAt + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt /** Number of auto-collection payment attempts. */ - @JsonProperty("num_attempts") @ExcludeMissing fun _numAttempts() = numAttempts + @JsonProperty("num_attempts") + @ExcludeMissing + fun _numAttempts(): JsonField = numAttempts /** * If Orb has ever attempted payment auto-collection for this invoice, this field will @@ -1547,7 +1888,7 @@ private constructor( */ @JsonProperty("previously_attempted_at") @ExcludeMissing - fun _previouslyAttemptedAt() = previouslyAttemptedAt + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt @JsonAnyGetter @ExcludeMissing @@ -1574,10 +1915,10 @@ private constructor( class Builder { - private var enabled: JsonField = JsonMissing.of() - private var nextAttemptAt: JsonField = JsonMissing.of() - private var numAttempts: JsonField = JsonMissing.of() - private var previouslyAttemptedAt: JsonField = JsonMissing.of() + private var enabled: JsonField? = null + private var nextAttemptAt: JsonField? = null + private var numAttempts: JsonField? = null + private var previouslyAttemptedAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1590,7 +1931,14 @@ private constructor( } /** True only if auto-collection is enabled for this invoice. */ - fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** True only if auto-collection is enabled for this invoice. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun enabled(enabled: Optional) = enabled(enabled.orElse(null) as Boolean?) /** True only if auto-collection is enabled for this invoice. */ fun enabled(enabled: JsonField) = apply { this.enabled = enabled } @@ -1600,8 +1948,16 @@ private constructor( * next attempt will occur. If dunning has been exhausted, or auto-collection is not * enabled for this invoice, this field will be `null`. */ - fun nextAttemptAt(nextAttemptAt: OffsetDateTime) = - nextAttemptAt(JsonField.of(nextAttemptAt)) + fun nextAttemptAt(nextAttemptAt: OffsetDateTime?) = + nextAttemptAt(JsonField.ofNullable(nextAttemptAt)) + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the + * next attempt will occur. If dunning has been exhausted, or auto-collection is not + * enabled for this invoice, this field will be `null`. + */ + fun nextAttemptAt(nextAttemptAt: Optional) = + nextAttemptAt(nextAttemptAt.orElse(null)) /** * If the invoice is scheduled for auto-collection, this field will reflect when the @@ -1613,7 +1969,15 @@ private constructor( } /** Number of auto-collection payment attempts. */ - fun numAttempts(numAttempts: Long) = numAttempts(JsonField.of(numAttempts)) + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** Number of auto-collection payment attempts. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun numAttempts(numAttempts: Optional) = + numAttempts(numAttempts.orElse(null) as Long?) /** Number of auto-collection payment attempts. */ fun numAttempts(numAttempts: JsonField) = apply { this.numAttempts = numAttempts } @@ -1626,8 +1990,19 @@ private constructor( * dunning has been exhausted (`previously_attempted_at` is non-null, but * `next_attempt_time` is null). */ - fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime) = - previouslyAttemptedAt(JsonField.of(previouslyAttemptedAt)) + fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime?) = + previouslyAttemptedAt(JsonField.ofNullable(previouslyAttemptedAt)) + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can + * be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: Optional) = + previouslyAttemptedAt(previouslyAttemptedAt.orElse(null)) /** * If Orb has ever attempted payment auto-collection for this invoice, this field will @@ -1662,10 +2037,12 @@ private constructor( fun build(): AutoCollection = AutoCollection( - enabled, - nextAttemptAt, - numAttempts, - previouslyAttemptedAt, + checkNotNull(enabled) { "`enabled` is required but was not set" }, + checkNotNull(nextAttemptAt) { "`nextAttemptAt` is required but was not set" }, + checkNotNull(numAttempts) { "`numAttempts` is required but was not set" }, + checkNotNull(previouslyAttemptedAt) { + "`previouslyAttemptedAt` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1727,17 +2104,19 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -1766,12 +2145,12 @@ private constructor( class Builder { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1785,27 +2164,39 @@ private constructor( additionalProperties = billingAddress.additionalProperties.toMutableMap() } - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) fun city(city: JsonField) = apply { this.city = city } - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) fun country(country: JsonField) = apply { this.country = country } - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) fun line1(line1: JsonField) = apply { this.line1 = line1 } - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) fun state(state: JsonField) = apply { this.state = state } @@ -1830,12 +2221,12 @@ private constructor( fun build(): BillingAddress = BillingAddress( - city, - country, - line1, - line2, - postalCode, - state, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(line1) { "`line1` is required but was not set" }, + checkNotNull(line2) { "`line2` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1905,26 +2296,28 @@ private constructor( fun voidedAt(): Optional = Optional.ofNullable(voidedAt.getNullable("voided_at")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("credit_note_number") @ExcludeMissing - fun _creditNoteNumber() = creditNoteNumber + fun _creditNoteNumber(): JsonField = creditNoteNumber /** An optional memo supplied on the credit note. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * If the credit note has a status of `void`, this gives a timestamp when the credit note * was voided. */ - @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt() = voidedAt + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt @JsonAnyGetter @ExcludeMissing @@ -1954,13 +2347,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var creditNoteNumber: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var voidedAt: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var memo: JsonField? = null + private var reason: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1987,7 +2380,10 @@ private constructor( } /** An optional memo supplied on the credit note. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo supplied on the credit note. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -2008,7 +2404,13 @@ private constructor( * If the credit note has a status of `void`, this gives a timestamp when the credit * note was voided. */ - fun voidedAt(voidedAt: OffsetDateTime) = voidedAt(JsonField.of(voidedAt)) + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit + * note was voided. + */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) /** * If the credit note has a status of `void`, this gives a timestamp when the credit @@ -2037,13 +2439,15 @@ private constructor( fun build(): CreditNote = CreditNote( - id, - creditNoteNumber, - memo, - reason, - total, - type, - voidedAt, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(creditNoteNumber) { + "`creditNoteNumber` is required but was not set" + }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(voidedAt) { "`voidedAt` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2083,11 +2487,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -2112,8 +2516,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2127,8 +2531,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -2155,8 +2562,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2248,36 +2657,46 @@ private constructor( fun type(): Type = type.getRequired("type") /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("action") @ExcludeMissing fun _action() = action + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The creation time of this transaction. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_note") @ExcludeMissing fun _creditNote() = creditNote + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** * The new value of the customer's balance prior to the transaction, in the customer's * currency. */ - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("invoice") @ExcludeMissing fun _invoice() = invoice + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice /** * The original value of the customer's balance prior to the transaction, in the customer's * currency. */ - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2310,16 +2729,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var action: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNote: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var invoice: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2362,14 +2781,19 @@ private constructor( this.createdAt = createdAt } - fun creditNote(creditNote: CreditNote) = creditNote(JsonField.of(creditNote)) + fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) + + fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) fun creditNote(creditNote: JsonField) = apply { this.creditNote = creditNote } /** An optional description provided for manual customer balance adjustments. */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: Optional) = description(description.orElse(null)) /** An optional description provided for manual customer balance adjustments. */ fun description(description: JsonField) = apply { @@ -2390,7 +2814,9 @@ private constructor( this.endingBalance = endingBalance } - fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) + + fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) fun invoice(invoice: JsonField) = apply { this.invoice = invoice } @@ -2434,16 +2860,18 @@ private constructor( fun build(): CustomerBalanceTransaction = CustomerBalanceTransaction( - id, - action, - amount, - createdAt, - creditNote, - description, - endingBalance, - invoice, - startingBalance, - type, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(action) { "`action` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNote) { "`creditNote` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(invoice) { "`invoice` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2556,7 +2984,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -2580,7 +3008,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2617,7 +3045,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) + fun build(): CreditNote = + CreditNote( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2653,7 +3085,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -2677,7 +3109,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2714,7 +3146,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) + fun build(): Invoice = + Invoice( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2936,11 +3372,11 @@ private constructor( fun value(): String = value.getRequired("value") - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -2966,9 +3402,9 @@ private constructor( class Builder { - private var country: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3012,9 +3448,9 @@ private constructor( fun build(): CustomerTaxId = CustomerTaxId( - country, - type, - value, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4420,33 +4856,39 @@ private constructor( fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") /** A unique ID for this line item. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The final amount after any discounts or minimums. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** The end date of the range of time applied for this line item's price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * [DEPRECATED] For configured prices that are split by a grouping key, this will be * populated with the key and a value. The `amount` and `subtotal` will be the values for * this particular grouping. */ - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The name of the price associated with this line item. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -4676,27 +5118,33 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** The start date of the range of time applied for this line item's price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * For complex pricing structures, the line item can be broken down further in * `sub_line_items`. */ - @JsonProperty("sub_line_items") @ExcludeMissing fun _subLineItems() = subLineItems + @JsonProperty("sub_line_items") + @ExcludeMissing + fun _subLineItems(): JsonField> = subLineItems /** The line amount before any line item-specific discounts or minimums. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - @JsonProperty("tax_amounts") @ExcludeMissing fun _taxAmounts() = taxAmounts + @JsonProperty("tax_amounts") + @ExcludeMissing + fun _taxAmounts(): JsonField> = taxAmounts @JsonAnyGetter @ExcludeMissing @@ -4735,22 +5183,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var subLineItems: JsonField> = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var taxAmounts: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var discount: JsonField? = null + private var endDate: JsonField? = null + private var grouping: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var price: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var subLineItems: JsonField>? = null + private var subtotal: JsonField? = null + private var taxAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4768,9 +5216,9 @@ private constructor( price = lineItem.price quantity = lineItem.quantity startDate = lineItem.startDate - subLineItems = lineItem.subLineItems + subLineItems = lineItem.subLineItems.map { it.toMutableList() } subtotal = lineItem.subtotal - taxAmounts = lineItem.taxAmounts + taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } additionalProperties = lineItem.additionalProperties.toMutableMap() } @@ -4786,10 +5234,24 @@ private constructor( /** The final amount after any discounts or minimums. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -4801,40 +5263,289 @@ private constructor( * populated with the key and a value. The `amount` and `subtotal` will be the values * for this particular grouping. */ - fun grouping(grouping: String) = grouping(JsonField.of(grouping)) + fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + + /** + * [DEPRECATED] For configured prices that are split by a grouping key, this will be + * populated with the key and a value. The `amount` and `subtotal` will be the values + * for this particular grouping. + */ + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) /** * [DEPRECATED] For configured prices that are split by a grouping key, this will be * populated with the key and a value. The `amount` and `subtotal` will be the values * for this particular grouping. */ - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The name of the price associated with this line item. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price associated with this line item. */ - fun name(name: JsonField) = apply { this.name = name } + fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The name of the price associated with this line item. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price associated with this line item. */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5064,7 +5775,7 @@ private constructor( * } * ``` */ - fun price(price: Price) = price(JsonField.of(price)) + fun price(price: Optional) = price(price.orElse(null)) /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5296,6 +6007,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -5320,7 +6096,24 @@ private constructor( * `sub_line_items`. */ fun subLineItems(subLineItems: JsonField>) = apply { - this.subLineItems = subLineItems + this.subLineItems = subLineItems.map { it.toMutableList() } + } + + /** + * For complex pricing structures, the line item can be broken down further in + * `sub_line_items`. + */ + fun addSubLineItem(subLineItem: SubLineItem) = apply { + subLineItems = + (subLineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(subLineItem) + } } /** The line amount before any line item-specific discounts or minimums. */ @@ -5340,7 +6133,24 @@ private constructor( * configured. */ fun taxAmounts(taxAmounts: JsonField>) = apply { - this.taxAmounts = taxAmounts + this.taxAmounts = taxAmounts.map { it.toMutableList() } + } + + /** + * An array of tax rates and their incurred tax amounts. Empty if no tax integration is + * configured. + */ + fun addTaxAmount(taxAmount: TaxAmount) = apply { + taxAmounts = + (taxAmounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(taxAmount) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -5364,22 +6174,24 @@ private constructor( fun build(): LineItem = LineItem( - id, - amount, - discount, - endDate, - grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, - name, - price, - quantity, - startDate, - subLineItems.map { it.toImmutable() }, - subtotal, - taxAmounts.map { it.toImmutable() }, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(subLineItems) { "`subLineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(taxAmounts) { "`taxAmounts` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -5414,10 +6226,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -5442,13 +6256,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -5465,7 +6279,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -5501,8 +6332,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5555,10 +6391,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -5583,13 +6421,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -5606,7 +6444,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -5642,8 +6497,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5872,17 +6732,23 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("matrix_config") @ExcludeMissing fun _matrixConfig() = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -5911,12 +6777,12 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var matrixConfig: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var matrixConfig: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5936,7 +6802,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -5983,12 +6851,14 @@ private constructor( fun build(): MatrixSubLineItem = MatrixSubLineItem( - amount, - grouping, - matrixConfig, - name, - quantity, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(matrixConfig) { + "`matrixConfig` is required but was not set" + }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6012,10 +6882,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -6040,8 +6910,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6057,7 +6927,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -6086,8 +6959,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6128,7 +7001,7 @@ private constructor( /** The ordered dimension values for this line item. */ @JsonProperty("dimension_values") @ExcludeMissing - fun _dimensionValues() = dimensionValues + fun _dimensionValues(): JsonField> = dimensionValues @JsonAnyGetter @ExcludeMissing @@ -6152,13 +7025,14 @@ private constructor( class Builder { - private var dimensionValues: JsonField> = JsonMissing.of() + private var dimensionValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { - dimensionValues = matrixConfig.dimensionValues + dimensionValues = + matrixConfig.dimensionValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -6168,7 +7042,21 @@ private constructor( /** The ordered dimension values for this line item. */ fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** The ordered dimension values for this line item. */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -6195,7 +7083,10 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensionValues.map { it.toImmutable() }, + checkNotNull(dimensionValues) { + "`dimensionValues` is required but was not set" + } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -6329,17 +7220,23 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("tier_config") @ExcludeMissing fun _tierConfig() = tierConfig + @JsonProperty("tier_config") + @ExcludeMissing + fun _tierConfig(): JsonField = tierConfig - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -6368,12 +7265,12 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var tierConfig: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var tierConfig: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6393,7 +7290,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -6439,12 +7338,12 @@ private constructor( fun build(): TierSubLineItem = TierSubLineItem( - amount, - grouping, - name, - quantity, - tierConfig, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(tierConfig) { "`tierConfig` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6468,10 +7367,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -6496,8 +7395,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6513,7 +7412,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -6542,8 +7444,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6590,11 +7492,17 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") - @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit() = firstUnit + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit - @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit() = lastUnit + @JsonProperty("last_unit") + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing @@ -6620,9 +7528,9 @@ private constructor( class Builder { - private var firstUnit: JsonField = JsonMissing.of() - private var lastUnit: JsonField = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var firstUnit: JsonField? = null + private var lastUnit: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6640,7 +7548,15 @@ private constructor( this.firstUnit = firstUnit } - fun lastUnit(lastUnit: Double) = lastUnit(JsonField.of(lastUnit)) + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) + + fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) + + @Suppress( + "USELESS_CAST" + ) // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lastUnit(lastUnit: Optional) = + lastUnit(lastUnit.orElse(null) as Double?) fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit @@ -6676,9 +7592,13 @@ private constructor( fun build(): TierConfig = TierConfig( - firstUnit, - lastUnit, - unitAmount, + checkNotNull(firstUnit) { + "`firstUnit` is required but was not set" + }, + checkNotNull(lastUnit) { "`lastUnit` is required but was not set" }, + checkNotNull(unitAmount) { + "`unitAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -6807,15 +7727,19 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -6843,11 +7767,11 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6866,7 +7790,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -6906,11 +7832,11 @@ private constructor( fun build(): OtherSubLineItem = OtherSubLineItem( - amount, - grouping, - name, - quantity, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6934,10 +7860,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -6962,8 +7888,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6979,7 +7905,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -7008,8 +7937,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7132,17 +8061,17 @@ private constructor( Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The human-readable description of the applied tax rate. */ @JsonProperty("tax_rate_description") @ExcludeMissing - fun _taxRateDescription() = taxRateDescription + fun _taxRateDescription(): JsonField = taxRateDescription /** The tax rate percentage, out of 100. */ @JsonProperty("tax_rate_percentage") @ExcludeMissing - fun _taxRatePercentage() = taxRatePercentage + fun _taxRatePercentage(): JsonField = taxRatePercentage @JsonAnyGetter @ExcludeMissing @@ -7168,9 +8097,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var taxRateDescription: JsonField = JsonMissing.of() - private var taxRatePercentage: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var taxRateDescription: JsonField? = null + private var taxRatePercentage: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7197,8 +8126,12 @@ private constructor( } /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String) = - taxRatePercentage(JsonField.of(taxRatePercentage)) + fun taxRatePercentage(taxRatePercentage: String?) = + taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: Optional) = + taxRatePercentage(taxRatePercentage.orElse(null)) /** The tax rate percentage, out of 100. */ fun taxRatePercentage(taxRatePercentage: JsonField) = apply { @@ -7229,9 +8162,13 @@ private constructor( fun build(): TaxAmount = TaxAmount( - amount, - taxRateDescription, - taxRatePercentage, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(taxRateDescription) { + "`taxRateDescription` is required but was not set" + }, + checkNotNull(taxRatePercentage) { + "`taxRatePercentage` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -7302,10 +8239,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -7330,13 +8269,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -7353,7 +8292,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -7385,8 +8341,11 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7519,10 +8478,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -7547,13 +8508,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -7570,7 +8531,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -7602,8 +8580,11 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7671,24 +8652,28 @@ private constructor( fun succeeded(): Boolean = succeeded.getRequired("succeeded") /** The ID of the payment attempt. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount of the payment attempt. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The time at which the payment attempt was created. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** The payment provider that attempted to collect the payment. */ - @JsonProperty("payment_provider") @ExcludeMissing fun _paymentProvider() = paymentProvider + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider /** The ID of the payment attempt in the payment provider. */ @JsonProperty("payment_provider_id") @ExcludeMissing - fun _paymentProviderId() = paymentProviderId + fun _paymentProviderId(): JsonField = paymentProviderId /** Whether the payment attempt succeeded. */ - @JsonProperty("succeeded") @ExcludeMissing fun _succeeded() = succeeded + @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded @JsonAnyGetter @ExcludeMissing @@ -7717,12 +8702,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var paymentProvider: JsonField = JsonMissing.of() - private var paymentProviderId: JsonField = JsonMissing.of() - private var succeeded: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var succeeded: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7757,8 +8742,12 @@ private constructor( } /** The payment provider that attempted to collect the payment. */ - fun paymentProvider(paymentProvider: PaymentProvider) = - paymentProvider(JsonField.of(paymentProvider)) + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.orElse(null)) /** The payment provider that attempted to collect the payment. */ fun paymentProvider(paymentProvider: JsonField) = apply { @@ -7766,8 +8755,12 @@ private constructor( } /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(paymentProviderId: String) = - paymentProviderId(JsonField.of(paymentProviderId)) + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) /** The ID of the payment attempt in the payment provider. */ fun paymentProviderId(paymentProviderId: JsonField) = apply { @@ -7801,12 +8794,16 @@ private constructor( fun build(): PaymentAttempt = PaymentAttempt( - id, - amount, - createdAt, - paymentProvider, - paymentProviderId, - succeeded, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(paymentProvider) { + "`paymentProvider` is required but was not set" + }, + checkNotNull(paymentProviderId) { + "`paymentProviderId` is required but was not set" + }, + checkNotNull(succeeded) { "`succeeded` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7919,17 +8916,19 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -7958,12 +8957,12 @@ private constructor( class Builder { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7977,27 +8976,39 @@ private constructor( additionalProperties = shippingAddress.additionalProperties.toMutableMap() } - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) fun city(city: JsonField) = apply { this.city = city } - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) fun country(country: JsonField) = apply { this.country = country } - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) fun line1(line1: JsonField) = apply { this.line1 = line1 } - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) fun state(state: JsonField) = apply { this.state = state } @@ -8022,12 +9033,12 @@ private constructor( fun build(): ShippingAddress = ShippingAddress( - city, - country, - line1, - line2, - postalCode, - state, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(line1) { "`line1` is required but was not set" }, + checkNotNull(line2) { "`line2` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -8136,7 +9147,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -8160,7 +9171,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8192,7 +9203,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Subscription = Subscription(id, additionalProperties.toImmutable()) + fun build(): Subscription = + Subscription( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt index bd815815..b3b87620 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceCreateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -21,6 +22,7 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** This endpoint is used to create a one-off invoice for a customer. */ class InvoiceCreateParams constructor( private val body: InvoiceCreateBody, @@ -77,12 +79,61 @@ constructor( */ fun willAutoIssue(): Optional = body.willAutoIssue() - fun _additionalHeaders(): Headers = additionalHeaders + /** An ISO 4217 currency string. Must be the same as the customer's currency if it is set. */ + fun _currency(): JsonField = body._currency() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set to the + * current time in the customer's timezone. + */ + fun _invoiceDate(): JsonField = body._invoiceDate() + + fun _lineItems(): JsonField> = body._lineItems() + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of '0' here represents that the invoice is due on issue, + * whereas a value of 30 represents that the customer has 30 days to pay the invoice. + */ + fun _netTerms(): JsonField = body._netTerms() + + /** + * The id of the `Customer` to create this invoice for. One of `customer_id` and + * `external_customer_id` are required. + */ + fun _customerId(): JsonField = body._customerId() + + /** An optional discount to attach to the invoice. */ + fun _discount(): JsonField = body._discount() + + /** + * The `external_customer_id` of the `Customer` to create this invoice for. One of `customer_id` + * and `external_customer_id` are required. + */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + /** An optional memo to attach to the invoice. */ + fun _memo(): JsonField = body._memo() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * When true, this invoice will automatically be issued upon creation. When false, the resulting + * invoice will require manual review to issue. Defaulted to false. + */ + fun _willAutoIssue(): JsonField = body._willAutoIssue() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): InvoiceCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -93,16 +144,36 @@ constructor( class InvoiceCreateBody @JsonCreator internal constructor( - @JsonProperty("currency") private val currency: String, - @JsonProperty("invoice_date") private val invoiceDate: OffsetDateTime, - @JsonProperty("line_items") private val lineItems: List, - @JsonProperty("net_terms") private val netTerms: Long, - @JsonProperty("customer_id") private val customerId: String?, - @JsonProperty("discount") private val discount: Discount?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("memo") private val memo: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("will_auto_issue") private val willAutoIssue: Boolean?, + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("invoice_date") + @ExcludeMissing + private val invoiceDate: JsonField = JsonMissing.of(), + @JsonProperty("line_items") + @ExcludeMissing + private val lineItems: JsonField> = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("discount") + @ExcludeMissing + private val discount: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("memo") + @ExcludeMissing + private val memo: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("will_auto_issue") + @ExcludeMissing + private val willAutoIssue: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -110,61 +181,140 @@ constructor( /** * An ISO 4217 currency string. Must be the same as the customer's currency if it is set. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") + + /** + * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set to + * the current time in the customer's timezone. + */ + fun invoiceDate(): OffsetDateTime = invoiceDate.getRequired("invoice_date") + + fun lineItems(): List = lineItems.getRequired("line_items") + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of '0' here represents that the invoice is due on issue, + * whereas a value of 30 represents that the customer has 30 days to pay the invoice. + */ + fun netTerms(): Long = netTerms.getRequired("net_terms") + + /** + * The id of the `Customer` to create this invoice for. One of `customer_id` and + * `external_customer_id` are required. + */ + fun customerId(): Optional = + Optional.ofNullable(customerId.getNullable("customer_id")) + + /** An optional discount to attach to the invoice. */ + fun discount(): Optional = Optional.ofNullable(discount.getNullable("discount")) + + /** + * The `external_customer_id` of the `Customer` to create this invoice for. One of + * `customer_id` and `external_customer_id` are required. + */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** An optional memo to attach to the invoice. */ + fun memo(): Optional = Optional.ofNullable(memo.getNullable("memo")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * When true, this invoice will automatically be issued upon creation. When false, the + * resulting invoice will require manual review to issue. Defaulted to false. + */ + fun willAutoIssue(): Optional = + Optional.ofNullable(willAutoIssue.getNullable("will_auto_issue")) + + /** + * An ISO 4217 currency string. Must be the same as the customer's currency if it is set. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set to * the current time in the customer's timezone. */ - @JsonProperty("invoice_date") fun invoiceDate(): OffsetDateTime = invoiceDate + @JsonProperty("invoice_date") + @ExcludeMissing + fun _invoiceDate(): JsonField = invoiceDate - @JsonProperty("line_items") fun lineItems(): List = lineItems + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of '0' here represents that the invoice is due on issue, * whereas a value of 30 represents that the customer has 30 days to pay the invoice. */ - @JsonProperty("net_terms") fun netTerms(): Long = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. */ @JsonProperty("customer_id") - fun customerId(): Optional = Optional.ofNullable(customerId) + @ExcludeMissing + fun _customerId(): JsonField = customerId /** An optional discount to attach to the invoice. */ - @JsonProperty("discount") fun discount(): Optional = Optional.ofNullable(discount) + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** * The `external_customer_id` of the `Customer` to create this invoice for. One of * `customer_id` and `external_customer_id` are required. */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId /** An optional memo to attach to the invoice. */ - @JsonProperty("memo") fun memo(): Optional = Optional.ofNullable(memo) + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * When true, this invoice will automatically be issued upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ @JsonProperty("will_auto_issue") - fun willAutoIssue(): Optional = Optional.ofNullable(willAutoIssue) + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceCreateBody = apply { + if (!validated) { + currency() + invoiceDate() + lineItems().forEach { it.validate() } + netTerms() + customerId() + discount() + externalCustomerId() + memo() + metadata().map { it.validate() } + willAutoIssue() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -174,23 +324,23 @@ constructor( class Builder { - private var currency: String? = null - private var invoiceDate: OffsetDateTime? = null - private var lineItems: MutableList? = null - private var netTerms: Long? = null - private var customerId: String? = null - private var discount: Discount? = null - private var externalCustomerId: String? = null - private var memo: String? = null - private var metadata: Metadata? = null - private var willAutoIssue: Boolean? = null + private var currency: JsonField? = null + private var invoiceDate: JsonField? = null + private var lineItems: JsonField>? = null + private var netTerms: JsonField? = null + private var customerId: JsonField = JsonMissing.of() + private var discount: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var memo: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var willAutoIssue: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(invoiceCreateBody: InvoiceCreateBody) = apply { currency = invoiceCreateBody.currency invoiceDate = invoiceCreateBody.invoiceDate - lineItems = invoiceCreateBody.lineItems.toMutableList() + lineItems = invoiceCreateBody.lineItems.map { it.toMutableList() } netTerms = invoiceCreateBody.netTerms customerId = invoiceCreateBody.customerId discount = invoiceCreateBody.discount @@ -205,20 +355,45 @@ constructor( * An ISO 4217 currency string. Must be the same as the customer's currency if it is * set. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * An ISO 4217 currency string. Must be the same as the customer's currency if it is + * set. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } /** * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set * to the current time in the customer's timezone. */ - fun invoiceDate(invoiceDate: OffsetDateTime) = apply { this.invoiceDate = invoiceDate } + fun invoiceDate(invoiceDate: OffsetDateTime) = invoiceDate(JsonField.of(invoiceDate)) + + /** + * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set + * to the current time in the customer's timezone. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + this.invoiceDate = invoiceDate + } - fun lineItems(lineItems: List) = apply { - this.lineItems = lineItems.toMutableList() + fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) + + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } } fun addLineItem(lineItem: LineItem) = apply { - lineItems = (lineItems ?: mutableListOf()).apply { add(lineItem) } + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(lineItem) + } } /** @@ -227,13 +402,21 @@ constructor( * issue, whereas a value of 30 represents that the customer has 30 days to pay the * invoice. */ - fun netTerms(netTerms: Long) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + + /** + * Determines the difference between the invoice issue date for subscription invoices as + * the date that they are due. A value of '0' here represents that the invoice is due on + * issue, whereas a value of 30 represents that the customer has 30 days to pay the + * invoice. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. */ - fun customerId(customerId: String?) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** * The id of the `Customer` to create this invoice for. One of `customer_id` and @@ -241,35 +424,39 @@ constructor( */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** + * The id of the `Customer` to create this invoice for. One of `customer_id` and + * `external_customer_id` are required. + */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** An optional discount to attach to the invoice. */ - fun discount(discount: Discount?) = apply { this.discount = discount } + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) /** An optional discount to attach to the invoice. */ fun discount(discount: Optional) = discount(discount.orElse(null)) - fun discount(percentageDiscount: PercentageDiscount) = apply { - this.discount = Discount.ofPercentageDiscount(percentageDiscount) - } + /** An optional discount to attach to the invoice. */ + fun discount(discount: JsonField) = apply { this.discount = discount } - fun discount(trialDiscount: TrialDiscount) = apply { - this.discount = Discount.ofTrialDiscount(trialDiscount) - } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) - fun discount(usageDiscount: Discount.UsageDiscount) = apply { - this.discount = Discount.ofUsageDiscount(usageDiscount) - } + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) - fun discount(amountDiscount: AmountDiscount) = apply { - this.discount = Discount.ofAmountDiscount(amountDiscount) - } + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) /** * The `external_customer_id` of the `Customer` to create this invoice for. One of * `customer_id` and `external_customer_id` are required. */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** * The `external_customer_id` of the `Customer` to create this invoice for. One of @@ -278,18 +465,29 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * The `external_customer_id` of the `Customer` to create this invoice for. One of + * `customer_id` and `external_customer_id` are required. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + /** An optional memo to attach to the invoice. */ - fun memo(memo: String?) = apply { this.memo = memo } + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) /** An optional memo to attach to the invoice. */ fun memo(memo: Optional) = memo(memo.orElse(null)) + /** An optional memo to attach to the invoice. */ + fun memo(memo: JsonField) = apply { this.memo = memo } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -299,26 +497,25 @@ constructor( fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** - * When true, this invoice will automatically be issued upon creation. When false, the - * resulting invoice will require manual review to issue. Defaulted to false. + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. */ - fun willAutoIssue(willAutoIssue: Boolean?) = apply { - this.willAutoIssue = willAutoIssue - } + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } /** * When true, this invoice will automatically be issued upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ - fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(willAutoIssue as Boolean?) + fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(JsonField.of(willAutoIssue)) /** * When true, this invoice will automatically be issued upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun willAutoIssue(willAutoIssue: Optional) = - willAutoIssue(willAutoIssue.orElse(null) as Boolean?) + fun willAutoIssue(willAutoIssue: JsonField) = apply { + this.willAutoIssue = willAutoIssue + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -344,7 +541,7 @@ constructor( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(invoiceDate) { "`invoiceDate` is required but was not set" }, checkNotNull(lineItems) { "`lineItems` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(netTerms) { "`netTerms` is required but was not set" }, customerId, discount, @@ -400,14 +597,29 @@ constructor( */ fun currency(currency: String) = apply { body.currency(currency) } + /** + * An ISO 4217 currency string. Must be the same as the customer's currency if it is set. + */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + /** * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set to * the current time in the customer's timezone. */ fun invoiceDate(invoiceDate: OffsetDateTime) = apply { body.invoiceDate(invoiceDate) } + /** + * Optional invoice date to set. Must be in the past, if not set, `invoice_date` is set to + * the current time in the customer's timezone. + */ + fun invoiceDate(invoiceDate: JsonField) = apply { + body.invoiceDate(invoiceDate) + } + fun lineItems(lineItems: List) = apply { body.lineItems(lineItems) } + fun lineItems(lineItems: JsonField>) = apply { body.lineItems(lineItems) } + fun addLineItem(lineItem: LineItem) = apply { body.addLineItem(lineItem) } /** @@ -417,6 +629,13 @@ constructor( */ fun netTerms(netTerms: Long) = apply { body.netTerms(netTerms) } + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of '0' here represents that the invoice is due on issue, + * whereas a value of 30 represents that the customer has 30 days to pay the invoice. + */ + fun netTerms(netTerms: JsonField) = apply { body.netTerms(netTerms) } + /** * The id of the `Customer` to create this invoice for. One of `customer_id` and * `external_customer_id` are required. @@ -429,12 +648,21 @@ constructor( */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** + * The id of the `Customer` to create this invoice for. One of `customer_id` and + * `external_customer_id` are required. + */ + fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + /** An optional discount to attach to the invoice. */ fun discount(discount: Discount?) = apply { body.discount(discount) } /** An optional discount to attach to the invoice. */ fun discount(discount: Optional) = discount(discount.orElse(null)) + /** An optional discount to attach to the invoice. */ + fun discount(discount: JsonField) = apply { body.discount(discount) } + fun discount(percentageDiscount: PercentageDiscount) = apply { body.discount(percentageDiscount) } @@ -460,12 +688,23 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** + * The `external_customer_id` of the `Customer` to create this invoice for. One of + * `customer_id` and `external_customer_id` are required. + */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + /** An optional memo to attach to the invoice. */ fun memo(memo: String?) = apply { body.memo(memo) } /** An optional memo to attach to the invoice. */ fun memo(memo: Optional) = memo(memo.orElse(null)) + /** An optional memo to attach to the invoice. */ + fun memo(memo: JsonField) = apply { body.memo(memo) } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -481,24 +720,44 @@ constructor( fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) /** - * When true, this invoice will automatically be issued upon creation. When false, the - * resulting invoice will require manual review to issue. Defaulted to false. + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. */ - fun willAutoIssue(willAutoIssue: Boolean?) = apply { body.willAutoIssue(willAutoIssue) } + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } /** * When true, this invoice will automatically be issued upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ - fun willAutoIssue(willAutoIssue: Boolean) = willAutoIssue(willAutoIssue as Boolean?) + fun willAutoIssue(willAutoIssue: Boolean) = apply { body.willAutoIssue(willAutoIssue) } /** * When true, this invoice will automatically be issued upon creation. When false, the * resulting invoice will require manual review to issue. Defaulted to false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun willAutoIssue(willAutoIssue: Optional) = - willAutoIssue(willAutoIssue.orElse(null) as Boolean?) + fun willAutoIssue(willAutoIssue: JsonField) = apply { + body.willAutoIssue(willAutoIssue) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -598,25 +857,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): InvoiceCreateParams = InvoiceCreateParams( body.build(), @@ -629,39 +869,92 @@ constructor( class LineItem @JsonCreator private constructor( - @JsonProperty("end_date") private val endDate: LocalDate, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("quantity") private val quantity: Double, - @JsonProperty("start_date") private val startDate: LocalDate, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A date string to specify the line item's end date in the customer's timezone. */ - @JsonProperty("end_date") fun endDate(): LocalDate = endDate + fun endDate(): LocalDate = endDate.getRequired("end_date") - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the line item. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") /** The number of units on the line item */ - @JsonProperty("quantity") fun quantity(): Double = quantity + fun quantity(): Double = quantity.getRequired("quantity") /** A date string to specify the line item's start date in the customer's timezone. */ - @JsonProperty("start_date") fun startDate(): LocalDate = startDate + fun startDate(): LocalDate = startDate.getRequired("start_date") - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** A date string to specify the line item's end date in the customer's timezone. */ + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate + + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the line item. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** The number of units on the line item */ + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity + + /** A date string to specify the line item's start date in the customer's timezone. */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): LineItem = apply { + if (!validated) { + endDate() + itemId() + modelType() + name() + quantity() + startDate() + unitConfig().validate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -671,13 +964,13 @@ constructor( class Builder { - private var endDate: LocalDate? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var quantity: Double? = null - private var startDate: LocalDate? = null - private var unitConfig: UnitConfig? = null + private var endDate: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var unitConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -693,22 +986,42 @@ constructor( } /** A date string to specify the line item's end date in the customer's timezone. */ - fun endDate(endDate: LocalDate) = apply { this.endDate = endDate } + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** A date string to specify the line item's end date in the customer's timezone. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the line item. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the line item. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** The number of units on the line item */ - fun quantity(quantity: Double) = apply { this.quantity = quantity } + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + + /** The number of units on the line item */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** A date string to specify the line item's start date in the customer's timezone. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) /** A date string to specify the line item's start date in the customer's timezone. */ - fun startDate(startDate: LocalDate) = apply { this.startDate = startDate } + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -797,18 +1110,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -818,7 +1147,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -828,7 +1157,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -912,6 +1246,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt index 66fbc147..87645db2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchParams.kt @@ -7,6 +7,9 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch an [`Invoice`](../guides/concepts#invoice) given an identifier. + */ class InvoiceFetchParams constructor( private val invoiceId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt index cdcc5670..4e9598bb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingParams.kt @@ -7,6 +7,10 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint can be used to fetch the upcoming [invoice](../guides/concepts#invoice) for the + * current billing period given a subscription. + */ class InvoiceFetchUpcomingParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt index 18f19f9d..047f4593 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceFetchUpcomingResponse.kt @@ -289,6 +289,12 @@ private constructor( fun customerTaxId(): Optional = Optional.ofNullable(customerTaxId.getNullable("customer_tax_id")) + /** + * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the + * first discount in the list will be returned. If the list is empty, `None` will be returned. + */ + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonValue = discount + fun discounts(): List = discounts.getRequired("discounts") /** When the invoice payment is due. */ @@ -420,32 +426,41 @@ private constructor( */ fun willAutoIssue(): Boolean = willAutoIssue.getRequired("will_auto_issue") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * This is the final amount required to be charged to the customer and reflects the application * of the customer balance to the `total` of the invoice. */ - @JsonProperty("amount_due") @ExcludeMissing fun _amountDue() = amountDue + @JsonProperty("amount_due") @ExcludeMissing fun _amountDue(): JsonField = amountDue - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection - @JsonProperty("billing_address") @ExcludeMissing fun _billingAddress() = billingAddress + @JsonProperty("billing_address") + @ExcludeMissing + fun _billingAddress(): JsonField = billingAddress /** The creation time of the resource in Orb. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** A list of credit notes associated with the invoice */ - @JsonProperty("credit_notes") @ExcludeMissing fun _creditNotes() = creditNotes + @JsonProperty("credit_notes") + @ExcludeMissing + fun _creditNotes(): JsonField> = creditNotes /** An ISO 4217 currency string or `credits` */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer @JsonProperty("customer_balance_transactions") @ExcludeMissing - fun _customerBalanceTransactions() = customerBalanceTransactions + fun _customerBalanceTransactions(): JsonField> = + customerBalanceTransactions /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to the @@ -553,18 +568,16 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - @JsonProperty("customer_tax_id") @ExcludeMissing fun _customerTaxId() = customerTaxId - - /** - * This field is deprecated in favor of `discounts`. If a `discounts` list is provided, the - * first discount in the list will be returned. If the list is empty, `None` will be returned. - */ - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("customer_tax_id") + @ExcludeMissing + fun _customerTaxId(): JsonField = customerTaxId - @JsonProperty("discounts") @ExcludeMissing fun _discounts() = discounts + @JsonProperty("discounts") + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** When the invoice payment is due. */ - @JsonProperty("due_date") @ExcludeMissing fun _dueDate() = dueDate + @JsonProperty("due_date") @ExcludeMissing fun _dueDate(): JsonField = dueDate /** * If the invoice has a status of `draft`, this will be the time that the invoice will be @@ -573,113 +586,145 @@ private constructor( */ @JsonProperty("eligible_to_issue_at") @ExcludeMissing - fun _eligibleToIssueAt() = eligibleToIssueAt + fun _eligibleToIssueAt(): JsonField = eligibleToIssueAt /** * A URL for the customer-facing invoice portal. This URL expires 30 days after the invoice's * due date, or 60 days after being re-generated through the UI. */ - @JsonProperty("hosted_invoice_url") @ExcludeMissing fun _hostedInvoiceUrl() = hostedInvoiceUrl + @JsonProperty("hosted_invoice_url") + @ExcludeMissing + fun _hostedInvoiceUrl(): JsonField = hostedInvoiceUrl /** * Automatically generated invoice number to help track and reconcile invoices. Invoice numbers * have a prefix such as `RFOBWG`. These can be sequential per account or customer. */ - @JsonProperty("invoice_number") @ExcludeMissing fun _invoiceNumber() = invoiceNumber + @JsonProperty("invoice_number") + @ExcludeMissing + fun _invoiceNumber(): JsonField = invoiceNumber /** The link to download the PDF representation of the `Invoice`. */ - @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf() = invoicePdf + @JsonProperty("invoice_pdf") @ExcludeMissing fun _invoicePdf(): JsonField = invoicePdf - @JsonProperty("invoice_source") @ExcludeMissing fun _invoiceSource() = invoiceSource + @JsonProperty("invoice_source") + @ExcludeMissing + fun _invoiceSource(): JsonField = invoiceSource /** * If the invoice failed to issue, this will be the last time it failed to issue (even if it is * now in a different state.) */ - @JsonProperty("issue_failed_at") @ExcludeMissing fun _issueFailedAt() = issueFailedAt + @JsonProperty("issue_failed_at") + @ExcludeMissing + fun _issueFailedAt(): JsonField = issueFailedAt /** * If the invoice has been issued, this will be the time it transitioned to `issued` (even if it * is now in a different state.) */ - @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt() = issuedAt + @JsonProperty("issued_at") @ExcludeMissing fun _issuedAt(): JsonField = issuedAt /** The breakdown of prices in this invoice. */ - @JsonProperty("line_items") @ExcludeMissing fun _lineItems() = lineItems + @JsonProperty("line_items") + @ExcludeMissing + fun _lineItems(): JsonField> = lineItems - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. */ - @JsonProperty("paid_at") @ExcludeMissing fun _paidAt() = paidAt + @JsonProperty("paid_at") @ExcludeMissing fun _paidAt(): JsonField = paidAt /** A list of payment attempts associated with the invoice */ - @JsonProperty("payment_attempts") @ExcludeMissing fun _paymentAttempts() = paymentAttempts + @JsonProperty("payment_attempts") + @ExcludeMissing + fun _paymentAttempts(): JsonField> = paymentAttempts /** * If payment was attempted on this invoice but failed, this will be the time of the most recent * attempt. */ - @JsonProperty("payment_failed_at") @ExcludeMissing fun _paymentFailedAt() = paymentFailedAt + @JsonProperty("payment_failed_at") + @ExcludeMissing + fun _paymentFailedAt(): JsonField = paymentFailedAt /** * If payment was attempted on this invoice, this will be the start time of the most recent * attempt. This field is especially useful for delayed-notification payment mechanisms (like * bank transfers), where payment can take 3 days or more. */ - @JsonProperty("payment_started_at") @ExcludeMissing fun _paymentStartedAt() = paymentStartedAt + @JsonProperty("payment_started_at") + @ExcludeMissing + fun _paymentStartedAt(): JsonField = paymentStartedAt /** * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to be * issued. */ - @JsonProperty("scheduled_issue_at") @ExcludeMissing fun _scheduledIssueAt() = scheduledIssueAt + @JsonProperty("scheduled_issue_at") + @ExcludeMissing + fun _scheduledIssueAt(): JsonField = scheduledIssueAt - @JsonProperty("shipping_address") @ExcludeMissing fun _shippingAddress() = shippingAddress + @JsonProperty("shipping_address") + @ExcludeMissing + fun _shippingAddress(): JsonField = shippingAddress - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("subscription") @ExcludeMissing fun _subscription() = subscription + @JsonProperty("subscription") + @ExcludeMissing + fun _subscription(): JsonField = subscription /** The total before any discounts and minimums are applied. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** * If the invoice failed to sync, this will be the last time an external invoicing provider sync * was attempted. This field will always be `null` for invoices using Orb Invoicing. */ - @JsonProperty("sync_failed_at") @ExcludeMissing fun _syncFailedAt() = syncFailedAt + @JsonProperty("sync_failed_at") + @ExcludeMissing + fun _syncFailedAt(): JsonField = syncFailedAt /** The scheduled date of the invoice */ - @JsonProperty("target_date") @ExcludeMissing fun _targetDate() = targetDate + @JsonProperty("target_date") + @ExcludeMissing + fun _targetDate(): JsonField = targetDate /** The total after any minimums and discounts have been applied. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total /** * If the invoice has a status of `void`, this gives a timestamp when the invoice was voided. */ - @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt() = voidedAt + @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt(): JsonField = voidedAt /** * This is true if the invoice will be automatically issued in the future, and false otherwise. */ - @JsonProperty("will_auto_issue") @ExcludeMissing fun _willAutoIssue() = willAutoIssue + @JsonProperty("will_auto_issue") + @ExcludeMissing + fun _willAutoIssue(): JsonField = willAutoIssue @JsonAnyGetter @ExcludeMissing @@ -742,48 +787,49 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amountDue: JsonField = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingAddress: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNotes: JsonField> = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var customerBalanceTransactions: JsonField> = - JsonMissing.of() - private var customerTaxId: JsonField = JsonMissing.of() - private var discount: JsonValue = JsonMissing.of() - private var discounts: JsonField> = JsonMissing.of() - private var dueDate: JsonField = JsonMissing.of() - private var eligibleToIssueAt: JsonField = JsonMissing.of() - private var hostedInvoiceUrl: JsonField = JsonMissing.of() - private var invoiceNumber: JsonField = JsonMissing.of() - private var invoicePdf: JsonField = JsonMissing.of() - private var invoiceSource: JsonField = JsonMissing.of() - private var issueFailedAt: JsonField = JsonMissing.of() - private var issuedAt: JsonField = JsonMissing.of() - private var lineItems: JsonField> = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var paidAt: JsonField = JsonMissing.of() - private var paymentAttempts: JsonField> = JsonMissing.of() - private var paymentFailedAt: JsonField = JsonMissing.of() - private var paymentStartedAt: JsonField = JsonMissing.of() - private var scheduledIssueAt: JsonField = JsonMissing.of() - private var shippingAddress: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var subscription: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var syncFailedAt: JsonField = JsonMissing.of() - private var targetDate: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() - private var voidedAt: JsonField = JsonMissing.of() - private var willAutoIssue: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amountDue: JsonField? = null + private var autoCollection: JsonField? = null + private var billingAddress: JsonField? = null + private var createdAt: JsonField? = null + private var creditNotes: JsonField>? = null + private var currency: JsonField? = null + private var customer: JsonField? = null + private var customerBalanceTransactions: + JsonField>? = + null + private var customerTaxId: JsonField? = null + private var discount: JsonValue? = null + private var discounts: JsonField>? = null + private var dueDate: JsonField? = null + private var eligibleToIssueAt: JsonField? = null + private var hostedInvoiceUrl: JsonField? = null + private var invoiceNumber: JsonField? = null + private var invoicePdf: JsonField? = null + private var invoiceSource: JsonField? = null + private var issueFailedAt: JsonField? = null + private var issuedAt: JsonField? = null + private var lineItems: JsonField>? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var memo: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var paidAt: JsonField? = null + private var paymentAttempts: JsonField>? = null + private var paymentFailedAt: JsonField? = null + private var paymentStartedAt: JsonField? = null + private var scheduledIssueAt: JsonField? = null + private var shippingAddress: JsonField? = null + private var status: JsonField? = null + private var subscription: JsonField? = null + private var subtotal: JsonField? = null + private var syncFailedAt: JsonField? = null + private var targetDate: JsonField? = null + private var total: JsonField? = null + private var voidedAt: JsonField? = null + private var willAutoIssue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -793,13 +839,14 @@ private constructor( autoCollection = invoiceFetchUpcomingResponse.autoCollection billingAddress = invoiceFetchUpcomingResponse.billingAddress createdAt = invoiceFetchUpcomingResponse.createdAt - creditNotes = invoiceFetchUpcomingResponse.creditNotes + creditNotes = invoiceFetchUpcomingResponse.creditNotes.map { it.toMutableList() } currency = invoiceFetchUpcomingResponse.currency customer = invoiceFetchUpcomingResponse.customer - customerBalanceTransactions = invoiceFetchUpcomingResponse.customerBalanceTransactions + customerBalanceTransactions = + invoiceFetchUpcomingResponse.customerBalanceTransactions.map { it.toMutableList() } customerTaxId = invoiceFetchUpcomingResponse.customerTaxId discount = invoiceFetchUpcomingResponse.discount - discounts = invoiceFetchUpcomingResponse.discounts + discounts = invoiceFetchUpcomingResponse.discounts.map { it.toMutableList() } dueDate = invoiceFetchUpcomingResponse.dueDate eligibleToIssueAt = invoiceFetchUpcomingResponse.eligibleToIssueAt hostedInvoiceUrl = invoiceFetchUpcomingResponse.hostedInvoiceUrl @@ -808,7 +855,7 @@ private constructor( invoiceSource = invoiceFetchUpcomingResponse.invoiceSource issueFailedAt = invoiceFetchUpcomingResponse.issueFailedAt issuedAt = invoiceFetchUpcomingResponse.issuedAt - lineItems = invoiceFetchUpcomingResponse.lineItems + lineItems = invoiceFetchUpcomingResponse.lineItems.map { it.toMutableList() } maximum = invoiceFetchUpcomingResponse.maximum maximumAmount = invoiceFetchUpcomingResponse.maximumAmount memo = invoiceFetchUpcomingResponse.memo @@ -816,7 +863,8 @@ private constructor( minimum = invoiceFetchUpcomingResponse.minimum minimumAmount = invoiceFetchUpcomingResponse.minimumAmount paidAt = invoiceFetchUpcomingResponse.paidAt - paymentAttempts = invoiceFetchUpcomingResponse.paymentAttempts + paymentAttempts = + invoiceFetchUpcomingResponse.paymentAttempts.map { it.toMutableList() } paymentFailedAt = invoiceFetchUpcomingResponse.paymentFailedAt paymentStartedAt = invoiceFetchUpcomingResponse.paymentStartedAt scheduledIssueAt = invoiceFetchUpcomingResponse.scheduledIssueAt @@ -855,8 +903,11 @@ private constructor( this.autoCollection = autoCollection } - fun billingAddress(billingAddress: BillingAddress) = - billingAddress(JsonField.of(billingAddress)) + fun billingAddress(billingAddress: BillingAddress?) = + billingAddress(JsonField.ofNullable(billingAddress)) + + fun billingAddress(billingAddress: Optional) = + billingAddress(billingAddress.orElse(null)) fun billingAddress(billingAddress: JsonField) = apply { this.billingAddress = billingAddress @@ -873,7 +924,21 @@ private constructor( /** A list of credit notes associated with the invoice */ fun creditNotes(creditNotes: JsonField>) = apply { - this.creditNotes = creditNotes + this.creditNotes = creditNotes.map { it.toMutableList() } + } + + /** A list of credit notes associated with the invoice */ + fun addCreditNote(creditNote: CreditNote) = apply { + creditNotes = + (creditNotes ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(creditNote) + } } /** An ISO 4217 currency string or `credits` */ @@ -892,7 +957,24 @@ private constructor( fun customerBalanceTransactions( customerBalanceTransactions: JsonField> - ) = apply { this.customerBalanceTransactions = customerBalanceTransactions } + ) = apply { + this.customerBalanceTransactions = + customerBalanceTransactions.map { it.toMutableList() } + } + + fun addCustomerBalanceTransaction(customerBalanceTransaction: CustomerBalanceTransaction) = + apply { + customerBalanceTransactions = + (customerBalanceTransactions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(customerBalanceTransaction) + } + } /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1000,7 +1082,117 @@ private constructor( * |Venezuela |`ve_rif` |Venezuelan RIF Number | * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | */ - fun customerTaxId(customerTaxId: CustomerTaxId) = customerTaxId(JsonField.of(customerTaxId)) + fun customerTaxId(customerTaxId: CustomerTaxId?) = + customerTaxId(JsonField.ofNullable(customerTaxId)) + + /** + * Tax IDs are commonly required to be displayed on customer invoices, which are added to + * the headers of invoices. + * + * ### Supported Tax ID Countries and Types + * |Country |Type |Description | + * |--------------------|------------|-------------------------------------------------------------------------------------------------------| + * |Andorra |`ad_nrt` |Andorran NRT Number | + * |Argentina |`ar_cuit` |Argentinian Tax ID Number | + * |Australia |`au_abn` |Australian Business Number (AU ABN) | + * |Australia |`au_arn` |Australian Taxation Office Reference Number | + * |Austria |`eu_vat` |European VAT Number | + * |Bahrain |`bh_vat` |Bahraini VAT Number | + * |Belgium |`eu_vat` |European VAT Number | + * |Bolivia |`bo_tin` |Bolivian Tax ID | + * |Brazil |`br_cnpj` |Brazilian CNPJ Number | + * |Brazil |`br_cpf` |Brazilian CPF Number | + * |Bulgaria |`bg_uic` |Bulgaria Unified Identification Code | + * |Bulgaria |`eu_vat` |European VAT Number | + * |Canada |`ca_bn` |Canadian BN | + * |Canada |`ca_gst_hst`|Canadian GST/HST Number | + * |Canada |`ca_pst_bc` |Canadian PST Number (British Columbia) | + * |Canada |`ca_pst_mb` |Canadian PST Number (Manitoba) | + * |Canada |`ca_pst_sk` |Canadian PST Number (Saskatchewan) | + * |Canada |`ca_qst` |Canadian QST Number (QuĆ©bec) | + * |Chile |`cl_tin` |Chilean TIN | + * |China |`cn_tin` |Chinese Tax ID | + * |Colombia |`co_nit` |Colombian NIT Number | + * |Costa Rica |`cr_tin` |Costa Rican Tax ID | + * |Croatia |`eu_vat` |European VAT Number | + * |Cyprus |`eu_vat` |European VAT Number | + * |Czech Republic |`eu_vat` |European VAT Number | + * |Denmark |`eu_vat` |European VAT Number | + * |Dominican Republic |`do_rcn` |Dominican RCN Number | + * |Ecuador |`ec_ruc` |Ecuadorian RUC Number | + * |Egypt |`eg_tin` |Egyptian Tax Identification Number | + * |El Salvador |`sv_nit` |El Salvadorian NIT Number | + * |Estonia |`eu_vat` |European VAT Number | + * |EU |`eu_oss_vat`|European One Stop Shop VAT Number for non-Union scheme | + * |Finland |`eu_vat` |European VAT Number | + * |France |`eu_vat` |European VAT Number | + * |Georgia |`ge_vat` |Georgian VAT | + * |Germany |`eu_vat` |European VAT Number | + * |Greece |`eu_vat` |European VAT Number | + * |Hong Kong |`hk_br` |Hong Kong BR Number | + * |Hungary |`eu_vat` |European VAT Number | + * |Hungary |`hu_tin` |Hungary Tax Number (adószĆ”m) | + * |Iceland |`is_vat` |Icelandic VAT | + * |India |`in_gst` |Indian GST Number | + * |Indonesia |`id_npwp` |Indonesian NPWP Number | + * |Ireland |`eu_vat` |European VAT Number | + * |Israel |`il_vat` |Israel VAT | + * |Italy |`eu_vat` |European VAT Number | + * |Japan |`jp_cn` |Japanese Corporate Number (_Hōjin Bangō_) | + * |Japan |`jp_rn` |Japanese Registered Foreign Businesses' Registration Number (_Tōroku Kokugai Jigyōsha no Tōroku Bangō_)| + * |Japan |`jp_trn` |Japanese Tax Registration Number (_Tōroku Bangō_) | + * |Kazakhstan |`kz_bin` |Kazakhstani Business Identification Number | + * |Kenya |`ke_pin` |Kenya Revenue Authority Personal Identification Number | + * |Latvia |`eu_vat` |European VAT Number | + * |Liechtenstein |`li_uid` |Liechtensteinian UID Number | + * |Lithuania |`eu_vat` |European VAT Number | + * |Luxembourg |`eu_vat` |European VAT Number | + * |Malaysia |`my_frp` |Malaysian FRP Number | + * |Malaysia |`my_itn` |Malaysian ITN | + * |Malaysia |`my_sst` |Malaysian SST Number | + * |Malta |`eu_vat ` |European VAT Number | + * |Mexico |`mx_rfc` |Mexican RFC Number | + * |Netherlands |`eu_vat` |European VAT Number | + * |New Zealand |`nz_gst` |New Zealand GST Number | + * |Nigeria |`ng_tin` |Nigerian Tax Identification Number | + * |Norway |`no_vat` |Norwegian VAT Number | + * |Norway |`no_voec` |Norwegian VAT on e-commerce Number | + * |Oman |`om_vat` |Omani VAT Number | + * |Peru |`pe_ruc` |Peruvian RUC Number | + * |Philippines |`ph_tin ` |Philippines Tax Identification Number | + * |Poland |`eu_vat` |European VAT Number | + * |Portugal |`eu_vat` |European VAT Number | + * |Romania |`eu_vat` |European VAT Number | + * |Romania |`ro_tin` |Romanian Tax ID Number | + * |Russia |`ru_inn` |Russian INN | + * |Russia |`ru_kpp` |Russian KPP | + * |Saudi Arabia |`sa_vat` |Saudi Arabia VAT | + * |Serbia |`rs_pib` |Serbian PIB Number | + * |Singapore |`sg_gst` |Singaporean GST | + * |Singapore |`sg_uen` |Singaporean UEN | + * |Slovakia |`eu_vat` |European VAT Number | + * |Slovenia |`eu_vat` |European VAT Number | + * |Slovenia |`si_tin` |Slovenia Tax Number (davčna Å”tevilka) | + * |South Africa |`za_vat` |South African VAT Number | + * |South Korea |`kr_brn` |Korean BRN | + * |Spain |`es_cif` |Spanish NIF Number (previously Spanish CIF Number) | + * |Spain |`eu_vat` |European VAT Number | + * |Sweden |`eu_vat` |European VAT Number | + * |Switzerland |`ch_vat` |Switzerland VAT Number | + * |Taiwan |`tw_vat` |Taiwanese VAT | + * |Thailand |`th_vat` |Thai VAT | + * |Turkey |`tr_tin` |Turkish Tax Identification Number | + * |Ukraine |`ua_vat` |Ukrainian VAT | + * |United Arab Emirates|`ae_trn` |United Arab Emirates TRN | + * |United Kingdom |`eu_vat` |Northern Ireland VAT Number | + * |United Kingdom |`gb_vat` |United Kingdom VAT Number | + * |United States |`us_ein` |United States EIN | + * |Uruguay |`uy_ruc` |Uruguayan RUC Number | + * |Venezuela |`ve_rif` |Venezuelan RIF Number | + * |Vietnam |`vn_tin` |Vietnamese Tax ID Number | + */ + fun customerTaxId(customerTaxId: Optional) = + customerTaxId(customerTaxId.orElse(null)) /** * Tax IDs are commonly required to be displayed on customer invoices, which are added to @@ -1122,7 +1314,20 @@ private constructor( fun discounts(discounts: List) = discounts(JsonField.of(discounts)) fun discounts(discounts: JsonField>) = apply { - this.discounts = discounts + this.discounts = discounts.map { it.toMutableList() } + } + + fun addDiscount(discount: InvoiceLevelDiscount) = apply { + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** When the invoice payment is due. */ @@ -1136,8 +1341,16 @@ private constructor( * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice * will automatically begin issuing at this time. */ - fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime) = - eligibleToIssueAt(JsonField.of(eligibleToIssueAt)) + fun eligibleToIssueAt(eligibleToIssueAt: OffsetDateTime?) = + eligibleToIssueAt(JsonField.ofNullable(eligibleToIssueAt)) + + /** + * If the invoice has a status of `draft`, this will be the time that the invoice will be + * eligible to be issued, otherwise it will be `null`. If `auto-issue` is true, the invoice + * will automatically begin issuing at this time. + */ + fun eligibleToIssueAt(eligibleToIssueAt: Optional) = + eligibleToIssueAt(eligibleToIssueAt.orElse(null)) /** * If the invoice has a status of `draft`, this will be the time that the invoice will be @@ -1152,8 +1365,15 @@ private constructor( * A URL for the customer-facing invoice portal. This URL expires 30 days after the * invoice's due date, or 60 days after being re-generated through the UI. */ - fun hostedInvoiceUrl(hostedInvoiceUrl: String) = - hostedInvoiceUrl(JsonField.of(hostedInvoiceUrl)) + fun hostedInvoiceUrl(hostedInvoiceUrl: String?) = + hostedInvoiceUrl(JsonField.ofNullable(hostedInvoiceUrl)) + + /** + * A URL for the customer-facing invoice portal. This URL expires 30 days after the + * invoice's due date, or 60 days after being re-generated through the UI. + */ + fun hostedInvoiceUrl(hostedInvoiceUrl: Optional) = + hostedInvoiceUrl(hostedInvoiceUrl.orElse(null)) /** * A URL for the customer-facing invoice portal. This URL expires 30 days after the @@ -1178,7 +1398,10 @@ private constructor( } /** The link to download the PDF representation of the `Invoice`. */ - fun invoicePdf(invoicePdf: String) = invoicePdf(JsonField.of(invoicePdf)) + fun invoicePdf(invoicePdf: String?) = invoicePdf(JsonField.ofNullable(invoicePdf)) + + /** The link to download the PDF representation of the `Invoice`. */ + fun invoicePdf(invoicePdf: Optional) = invoicePdf(invoicePdf.orElse(null)) /** The link to download the PDF representation of the `Invoice`. */ fun invoicePdf(invoicePdf: JsonField) = apply { this.invoicePdf = invoicePdf } @@ -1193,8 +1416,15 @@ private constructor( * If the invoice failed to issue, this will be the last time it failed to issue (even if it * is now in a different state.) */ - fun issueFailedAt(issueFailedAt: OffsetDateTime) = - issueFailedAt(JsonField.of(issueFailedAt)) + fun issueFailedAt(issueFailedAt: OffsetDateTime?) = + issueFailedAt(JsonField.ofNullable(issueFailedAt)) + + /** + * If the invoice failed to issue, this will be the last time it failed to issue (even if it + * is now in a different state.) + */ + fun issueFailedAt(issueFailedAt: Optional) = + issueFailedAt(issueFailedAt.orElse(null)) /** * If the invoice failed to issue, this will be the last time it failed to issue (even if it @@ -1208,7 +1438,13 @@ private constructor( * If the invoice has been issued, this will be the time it transitioned to `issued` (even * if it is now in a different state.) */ - fun issuedAt(issuedAt: OffsetDateTime) = issuedAt(JsonField.of(issuedAt)) + fun issuedAt(issuedAt: OffsetDateTime?) = issuedAt(JsonField.ofNullable(issuedAt)) + + /** + * If the invoice has been issued, this will be the time it transitioned to `issued` (even + * if it is now in a different state.) + */ + fun issuedAt(issuedAt: Optional) = issuedAt(issuedAt.orElse(null)) /** * If the invoice has been issued, this will be the time it transitioned to `issued` (even @@ -1220,20 +1456,45 @@ private constructor( fun lineItems(lineItems: List) = lineItems(JsonField.of(lineItems)) /** The breakdown of prices in this invoice. */ - fun lineItems(lineItems: JsonField>) = apply { this.lineItems = lineItems } + fun lineItems(lineItems: JsonField>) = apply { + this.lineItems = lineItems.map { it.toMutableList() } + } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + /** The breakdown of prices in this invoice. */ + fun addLineItem(lineItem: LineItem) = apply { + lineItems = + (lineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(lineItem) + } + } + + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount } /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -1252,11 +1513,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -1265,7 +1532,12 @@ private constructor( /** * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. */ - fun paidAt(paidAt: OffsetDateTime) = paidAt(JsonField.of(paidAt)) + fun paidAt(paidAt: OffsetDateTime?) = paidAt(JsonField.ofNullable(paidAt)) + + /** + * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. + */ + fun paidAt(paidAt: Optional) = paidAt(paidAt.orElse(null)) /** * If the invoice has a status of `paid`, this gives a timestamp when the invoice was paid. @@ -1278,15 +1550,36 @@ private constructor( /** A list of payment attempts associated with the invoice */ fun paymentAttempts(paymentAttempts: JsonField>) = apply { - this.paymentAttempts = paymentAttempts + this.paymentAttempts = paymentAttempts.map { it.toMutableList() } + } + + /** A list of payment attempts associated with the invoice */ + fun addPaymentAttempt(paymentAttempt: PaymentAttempt) = apply { + paymentAttempts = + (paymentAttempts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(paymentAttempt) + } } /** * If payment was attempted on this invoice but failed, this will be the time of the most * recent attempt. */ - fun paymentFailedAt(paymentFailedAt: OffsetDateTime) = - paymentFailedAt(JsonField.of(paymentFailedAt)) + fun paymentFailedAt(paymentFailedAt: OffsetDateTime?) = + paymentFailedAt(JsonField.ofNullable(paymentFailedAt)) + + /** + * If payment was attempted on this invoice but failed, this will be the time of the most + * recent attempt. + */ + fun paymentFailedAt(paymentFailedAt: Optional) = + paymentFailedAt(paymentFailedAt.orElse(null)) /** * If payment was attempted on this invoice but failed, this will be the time of the most @@ -1301,8 +1594,16 @@ private constructor( * attempt. This field is especially useful for delayed-notification payment mechanisms * (like bank transfers), where payment can take 3 days or more. */ - fun paymentStartedAt(paymentStartedAt: OffsetDateTime) = - paymentStartedAt(JsonField.of(paymentStartedAt)) + fun paymentStartedAt(paymentStartedAt: OffsetDateTime?) = + paymentStartedAt(JsonField.ofNullable(paymentStartedAt)) + + /** + * If payment was attempted on this invoice, this will be the start time of the most recent + * attempt. This field is especially useful for delayed-notification payment mechanisms + * (like bank transfers), where payment can take 3 days or more. + */ + fun paymentStartedAt(paymentStartedAt: Optional) = + paymentStartedAt(paymentStartedAt.orElse(null)) /** * If payment was attempted on this invoice, this will be the start time of the most recent @@ -1317,8 +1618,15 @@ private constructor( * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to * be issued. */ - fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime) = - scheduledIssueAt(JsonField.of(scheduledIssueAt)) + fun scheduledIssueAt(scheduledIssueAt: OffsetDateTime?) = + scheduledIssueAt(JsonField.ofNullable(scheduledIssueAt)) + + /** + * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to + * be issued. + */ + fun scheduledIssueAt(scheduledIssueAt: Optional) = + scheduledIssueAt(scheduledIssueAt.orElse(null)) /** * If the invoice is in draft, this timestamp will reflect when the invoice is scheduled to @@ -1328,8 +1636,11 @@ private constructor( this.scheduledIssueAt = scheduledIssueAt } - fun shippingAddress(shippingAddress: ShippingAddress) = - shippingAddress(JsonField.of(shippingAddress)) + fun shippingAddress(shippingAddress: ShippingAddress?) = + shippingAddress(JsonField.ofNullable(shippingAddress)) + + fun shippingAddress(shippingAddress: Optional) = + shippingAddress(shippingAddress.orElse(null)) fun shippingAddress(shippingAddress: JsonField) = apply { this.shippingAddress = shippingAddress @@ -1339,7 +1650,11 @@ private constructor( fun status(status: JsonField) = apply { this.status = status } - fun subscription(subscription: Subscription) = subscription(JsonField.of(subscription)) + fun subscription(subscription: Subscription?) = + subscription(JsonField.ofNullable(subscription)) + + fun subscription(subscription: Optional) = + subscription(subscription.orElse(null)) fun subscription(subscription: JsonField) = apply { this.subscription = subscription @@ -1355,7 +1670,15 @@ private constructor( * If the invoice failed to sync, this will be the last time an external invoicing provider * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. */ - fun syncFailedAt(syncFailedAt: OffsetDateTime) = syncFailedAt(JsonField.of(syncFailedAt)) + fun syncFailedAt(syncFailedAt: OffsetDateTime?) = + syncFailedAt(JsonField.ofNullable(syncFailedAt)) + + /** + * If the invoice failed to sync, this will be the last time an external invoicing provider + * sync was attempted. This field will always be `null` for invoices using Orb Invoicing. + */ + fun syncFailedAt(syncFailedAt: Optional) = + syncFailedAt(syncFailedAt.orElse(null)) /** * If the invoice failed to sync, this will be the last time an external invoicing provider @@ -1383,7 +1706,13 @@ private constructor( * If the invoice has a status of `void`, this gives a timestamp when the invoice was * voided. */ - fun voidedAt(voidedAt: OffsetDateTime) = voidedAt(JsonField.of(voidedAt)) + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * If the invoice has a status of `void`, this gives a timestamp when the invoice was + * voided. + */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) /** * If the invoice has a status of `void`, this gives a timestamp when the invoice was @@ -1426,47 +1755,56 @@ private constructor( fun build(): InvoiceFetchUpcomingResponse = InvoiceFetchUpcomingResponse( - id, - amountDue, - autoCollection, - billingAddress, - createdAt, - creditNotes.map { it.toImmutable() }, - currency, - customer, - customerBalanceTransactions.map { it.toImmutable() }, - customerTaxId, - discount, - discounts.map { it.toImmutable() }, - dueDate, - eligibleToIssueAt, - hostedInvoiceUrl, - invoiceNumber, - invoicePdf, - invoiceSource, - issueFailedAt, - issuedAt, - lineItems.map { it.toImmutable() }, - maximum, - maximumAmount, - memo, - metadata, - minimum, - minimumAmount, - paidAt, - paymentAttempts.map { it.toImmutable() }, - paymentFailedAt, - paymentStartedAt, - scheduledIssueAt, - shippingAddress, - status, - subscription, - subtotal, - syncFailedAt, - targetDate, - total, - voidedAt, - willAutoIssue, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amountDue) { "`amountDue` is required but was not set" }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingAddress) { "`billingAddress` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNotes) { "`creditNotes` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(customerBalanceTransactions) { + "`customerBalanceTransactions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(customerTaxId) { "`customerTaxId` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(discounts) { "`discounts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(dueDate) { "`dueDate` is required but was not set" }, + checkNotNull(eligibleToIssueAt) { + "`eligibleToIssueAt` is required but was not set" + }, + checkNotNull(hostedInvoiceUrl) { "`hostedInvoiceUrl` is required but was not set" }, + checkNotNull(invoiceNumber) { "`invoiceNumber` is required but was not set" }, + checkNotNull(invoicePdf) { "`invoicePdf` is required but was not set" }, + checkNotNull(invoiceSource) { "`invoiceSource` is required but was not set" }, + checkNotNull(issueFailedAt) { "`issueFailedAt` is required but was not set" }, + checkNotNull(issuedAt) { "`issuedAt` is required but was not set" }, + checkNotNull(lineItems) { "`lineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(paidAt) { "`paidAt` is required but was not set" }, + checkNotNull(paymentAttempts) { "`paymentAttempts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(paymentFailedAt) { "`paymentFailedAt` is required but was not set" }, + checkNotNull(paymentStartedAt) { "`paymentStartedAt` is required but was not set" }, + checkNotNull(scheduledIssueAt) { "`scheduledIssueAt` is required but was not set" }, + checkNotNull(shippingAddress) { "`shippingAddress` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(subscription) { "`subscription` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(syncFailedAt) { "`syncFailedAt` is required but was not set" }, + checkNotNull(targetDate) { "`targetDate` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, + checkNotNull(voidedAt) { "`voidedAt` is required but was not set" }, + checkNotNull(willAutoIssue) { "`willAutoIssue` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1518,17 +1856,21 @@ private constructor( Optional.ofNullable(previouslyAttemptedAt.getNullable("previously_attempted_at")) /** True only if auto-collection is enabled for this invoice. */ - @JsonProperty("enabled") @ExcludeMissing fun _enabled() = enabled + @JsonProperty("enabled") @ExcludeMissing fun _enabled(): JsonField = enabled /** * If the invoice is scheduled for auto-collection, this field will reflect when the next * attempt will occur. If dunning has been exhausted, or auto-collection is not enabled for * this invoice, this field will be `null`. */ - @JsonProperty("next_attempt_at") @ExcludeMissing fun _nextAttemptAt() = nextAttemptAt + @JsonProperty("next_attempt_at") + @ExcludeMissing + fun _nextAttemptAt(): JsonField = nextAttemptAt /** Number of auto-collection payment attempts. */ - @JsonProperty("num_attempts") @ExcludeMissing fun _numAttempts() = numAttempts + @JsonProperty("num_attempts") + @ExcludeMissing + fun _numAttempts(): JsonField = numAttempts /** * If Orb has ever attempted payment auto-collection for this invoice, this field will @@ -1540,7 +1882,7 @@ private constructor( */ @JsonProperty("previously_attempted_at") @ExcludeMissing - fun _previouslyAttemptedAt() = previouslyAttemptedAt + fun _previouslyAttemptedAt(): JsonField = previouslyAttemptedAt @JsonAnyGetter @ExcludeMissing @@ -1567,10 +1909,10 @@ private constructor( class Builder { - private var enabled: JsonField = JsonMissing.of() - private var nextAttemptAt: JsonField = JsonMissing.of() - private var numAttempts: JsonField = JsonMissing.of() - private var previouslyAttemptedAt: JsonField = JsonMissing.of() + private var enabled: JsonField? = null + private var nextAttemptAt: JsonField? = null + private var numAttempts: JsonField? = null + private var previouslyAttemptedAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1583,7 +1925,14 @@ private constructor( } /** True only if auto-collection is enabled for this invoice. */ - fun enabled(enabled: Boolean) = enabled(JsonField.of(enabled)) + fun enabled(enabled: Boolean?) = enabled(JsonField.ofNullable(enabled)) + + /** True only if auto-collection is enabled for this invoice. */ + fun enabled(enabled: Boolean) = enabled(enabled as Boolean?) + + /** True only if auto-collection is enabled for this invoice. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun enabled(enabled: Optional) = enabled(enabled.orElse(null) as Boolean?) /** True only if auto-collection is enabled for this invoice. */ fun enabled(enabled: JsonField) = apply { this.enabled = enabled } @@ -1593,8 +1942,16 @@ private constructor( * next attempt will occur. If dunning has been exhausted, or auto-collection is not * enabled for this invoice, this field will be `null`. */ - fun nextAttemptAt(nextAttemptAt: OffsetDateTime) = - nextAttemptAt(JsonField.of(nextAttemptAt)) + fun nextAttemptAt(nextAttemptAt: OffsetDateTime?) = + nextAttemptAt(JsonField.ofNullable(nextAttemptAt)) + + /** + * If the invoice is scheduled for auto-collection, this field will reflect when the + * next attempt will occur. If dunning has been exhausted, or auto-collection is not + * enabled for this invoice, this field will be `null`. + */ + fun nextAttemptAt(nextAttemptAt: Optional) = + nextAttemptAt(nextAttemptAt.orElse(null)) /** * If the invoice is scheduled for auto-collection, this field will reflect when the @@ -1606,7 +1963,15 @@ private constructor( } /** Number of auto-collection payment attempts. */ - fun numAttempts(numAttempts: Long) = numAttempts(JsonField.of(numAttempts)) + fun numAttempts(numAttempts: Long?) = numAttempts(JsonField.ofNullable(numAttempts)) + + /** Number of auto-collection payment attempts. */ + fun numAttempts(numAttempts: Long) = numAttempts(numAttempts as Long?) + + /** Number of auto-collection payment attempts. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun numAttempts(numAttempts: Optional) = + numAttempts(numAttempts.orElse(null) as Long?) /** Number of auto-collection payment attempts. */ fun numAttempts(numAttempts: JsonField) = apply { this.numAttempts = numAttempts } @@ -1619,8 +1984,19 @@ private constructor( * dunning has been exhausted (`previously_attempted_at` is non-null, but * `next_attempt_time` is null). */ - fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime) = - previouslyAttemptedAt(JsonField.of(previouslyAttemptedAt)) + fun previouslyAttemptedAt(previouslyAttemptedAt: OffsetDateTime?) = + previouslyAttemptedAt(JsonField.ofNullable(previouslyAttemptedAt)) + + /** + * If Orb has ever attempted payment auto-collection for this invoice, this field will + * reflect when that attempt occurred. In conjunction with `next_attempt_at`, this can + * be used to tell whether the invoice is currently in dunning (that is, + * `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), or if + * dunning has been exhausted (`previously_attempted_at` is non-null, but + * `next_attempt_time` is null). + */ + fun previouslyAttemptedAt(previouslyAttemptedAt: Optional) = + previouslyAttemptedAt(previouslyAttemptedAt.orElse(null)) /** * If Orb has ever attempted payment auto-collection for this invoice, this field will @@ -1655,10 +2031,12 @@ private constructor( fun build(): AutoCollection = AutoCollection( - enabled, - nextAttemptAt, - numAttempts, - previouslyAttemptedAt, + checkNotNull(enabled) { "`enabled` is required but was not set" }, + checkNotNull(nextAttemptAt) { "`nextAttemptAt` is required but was not set" }, + checkNotNull(numAttempts) { "`numAttempts` is required but was not set" }, + checkNotNull(previouslyAttemptedAt) { + "`previouslyAttemptedAt` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1720,17 +2098,19 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -1759,12 +2139,12 @@ private constructor( class Builder { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1778,27 +2158,39 @@ private constructor( additionalProperties = billingAddress.additionalProperties.toMutableMap() } - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) fun city(city: JsonField) = apply { this.city = city } - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) fun country(country: JsonField) = apply { this.country = country } - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) fun line1(line1: JsonField) = apply { this.line1 = line1 } - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) fun state(state: JsonField) = apply { this.state = state } @@ -1823,12 +2215,12 @@ private constructor( fun build(): BillingAddress = BillingAddress( - city, - country, - line1, - line2, - postalCode, - state, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(line1) { "`line1` is required but was not set" }, + checkNotNull(line2) { "`line2` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1898,26 +2290,28 @@ private constructor( fun voidedAt(): Optional = Optional.ofNullable(voidedAt.getNullable("voided_at")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("credit_note_number") @ExcludeMissing - fun _creditNoteNumber() = creditNoteNumber + fun _creditNoteNumber(): JsonField = creditNoteNumber /** An optional memo supplied on the credit note. */ - @JsonProperty("memo") @ExcludeMissing fun _memo() = memo + @JsonProperty("memo") @ExcludeMissing fun _memo(): JsonField = memo - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type /** * If the credit note has a status of `void`, this gives a timestamp when the credit note * was voided. */ - @JsonProperty("voided_at") @ExcludeMissing fun _voidedAt() = voidedAt + @JsonProperty("voided_at") + @ExcludeMissing + fun _voidedAt(): JsonField = voidedAt @JsonAnyGetter @ExcludeMissing @@ -1947,13 +2341,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var creditNoteNumber: JsonField = JsonMissing.of() - private var memo: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var voidedAt: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var creditNoteNumber: JsonField? = null + private var memo: JsonField? = null + private var reason: JsonField? = null + private var total: JsonField? = null + private var type: JsonField? = null + private var voidedAt: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1980,7 +2374,10 @@ private constructor( } /** An optional memo supplied on the credit note. */ - fun memo(memo: String) = memo(JsonField.of(memo)) + fun memo(memo: String?) = memo(JsonField.ofNullable(memo)) + + /** An optional memo supplied on the credit note. */ + fun memo(memo: Optional) = memo(memo.orElse(null)) /** An optional memo supplied on the credit note. */ fun memo(memo: JsonField) = apply { this.memo = memo } @@ -2001,7 +2398,13 @@ private constructor( * If the credit note has a status of `void`, this gives a timestamp when the credit * note was voided. */ - fun voidedAt(voidedAt: OffsetDateTime) = voidedAt(JsonField.of(voidedAt)) + fun voidedAt(voidedAt: OffsetDateTime?) = voidedAt(JsonField.ofNullable(voidedAt)) + + /** + * If the credit note has a status of `void`, this gives a timestamp when the credit + * note was voided. + */ + fun voidedAt(voidedAt: Optional) = voidedAt(voidedAt.orElse(null)) /** * If the credit note has a status of `void`, this gives a timestamp when the credit @@ -2030,13 +2433,15 @@ private constructor( fun build(): CreditNote = CreditNote( - id, - creditNoteNumber, - memo, - reason, - total, - type, - voidedAt, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(creditNoteNumber) { + "`creditNoteNumber` is required but was not set" + }, + checkNotNull(memo) { "`memo` is required but was not set" }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(voidedAt) { "`voidedAt` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2076,11 +2481,11 @@ private constructor( fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("external_customer_id") @ExcludeMissing - fun _externalCustomerId() = externalCustomerId + fun _externalCustomerId(): JsonField = externalCustomerId @JsonAnyGetter @ExcludeMissing @@ -2105,8 +2510,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalCustomerId: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalCustomerId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2120,8 +2525,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun externalCustomerId(externalCustomerId: String) = - externalCustomerId(JsonField.of(externalCustomerId)) + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) + + fun externalCustomerId(externalCustomerId: Optional) = + externalCustomerId(externalCustomerId.orElse(null)) fun externalCustomerId(externalCustomerId: JsonField) = apply { this.externalCustomerId = externalCustomerId @@ -2148,8 +2556,10 @@ private constructor( fun build(): Customer = Customer( - id, - externalCustomerId, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalCustomerId) { + "`externalCustomerId` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2241,36 +2651,46 @@ private constructor( fun type(): Type = type.getRequired("type") /** A unique id for this transaction. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("action") @ExcludeMissing fun _action() = action + @JsonProperty("action") @ExcludeMissing fun _action(): JsonField = action /** The value of the amount changed in the transaction. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The creation time of this transaction. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("credit_note") @ExcludeMissing fun _creditNote() = creditNote + @JsonProperty("credit_note") + @ExcludeMissing + fun _creditNote(): JsonField = creditNote /** An optional description provided for manual customer balance adjustments. */ - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description /** * The new value of the customer's balance prior to the transaction, in the customer's * currency. */ - @JsonProperty("ending_balance") @ExcludeMissing fun _endingBalance() = endingBalance + @JsonProperty("ending_balance") + @ExcludeMissing + fun _endingBalance(): JsonField = endingBalance - @JsonProperty("invoice") @ExcludeMissing fun _invoice() = invoice + @JsonProperty("invoice") @ExcludeMissing fun _invoice(): JsonField = invoice /** * The original value of the customer's balance prior to the transaction, in the customer's * currency. */ - @JsonProperty("starting_balance") @ExcludeMissing fun _startingBalance() = startingBalance + @JsonProperty("starting_balance") + @ExcludeMissing + fun _startingBalance(): JsonField = startingBalance - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2303,16 +2723,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var action: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditNote: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var endingBalance: JsonField = JsonMissing.of() - private var invoice: JsonField = JsonMissing.of() - private var startingBalance: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var action: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var creditNote: JsonField? = null + private var description: JsonField? = null + private var endingBalance: JsonField? = null + private var invoice: JsonField? = null + private var startingBalance: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2355,14 +2775,19 @@ private constructor( this.createdAt = createdAt } - fun creditNote(creditNote: CreditNote) = creditNote(JsonField.of(creditNote)) + fun creditNote(creditNote: CreditNote?) = creditNote(JsonField.ofNullable(creditNote)) + + fun creditNote(creditNote: Optional) = creditNote(creditNote.orElse(null)) fun creditNote(creditNote: JsonField) = apply { this.creditNote = creditNote } /** An optional description provided for manual customer balance adjustments. */ - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + /** An optional description provided for manual customer balance adjustments. */ + fun description(description: Optional) = description(description.orElse(null)) /** An optional description provided for manual customer balance adjustments. */ fun description(description: JsonField) = apply { @@ -2383,7 +2808,9 @@ private constructor( this.endingBalance = endingBalance } - fun invoice(invoice: Invoice) = invoice(JsonField.of(invoice)) + fun invoice(invoice: Invoice?) = invoice(JsonField.ofNullable(invoice)) + + fun invoice(invoice: Optional) = invoice(invoice.orElse(null)) fun invoice(invoice: JsonField) = apply { this.invoice = invoice } @@ -2427,16 +2854,18 @@ private constructor( fun build(): CustomerBalanceTransaction = CustomerBalanceTransaction( - id, - action, - amount, - createdAt, - creditNote, - description, - endingBalance, - invoice, - startingBalance, - type, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(action) { "`action` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditNote) { "`creditNote` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(endingBalance) { "`endingBalance` is required but was not set" }, + checkNotNull(invoice) { "`invoice` is required but was not set" }, + checkNotNull(startingBalance) { + "`startingBalance` is required but was not set" + }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2549,7 +2978,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The id of the Credit note */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -2573,7 +3002,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2610,7 +3039,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): CreditNote = CreditNote(id, additionalProperties.toImmutable()) + fun build(): CreditNote = + CreditNote( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2646,7 +3079,7 @@ private constructor( fun id(): String = id.getRequired("id") /** The Invoice id */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -2670,7 +3103,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2707,7 +3140,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Invoice = Invoice(id, additionalProperties.toImmutable()) + fun build(): Invoice = + Invoice( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2929,11 +3366,11 @@ private constructor( fun value(): String = value.getRequired("value") - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -2959,9 +3396,9 @@ private constructor( class Builder { - private var country: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var country: JsonField? = null + private var type: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3005,9 +3442,9 @@ private constructor( fun build(): CustomerTaxId = CustomerTaxId( - country, - type, - value, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4413,33 +4850,39 @@ private constructor( fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") /** A unique ID for this line item. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The final amount after any discounts or minimums. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** The end date of the range of time applied for this line item's price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * [DEPRECATED] For configured prices that are split by a grouping key, this will be * populated with the key and a value. The `amount` and `subtotal` will be the values for * this particular grouping. */ - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The name of the price associated with this line item. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -4669,27 +5112,33 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** The start date of the range of time applied for this line item's price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * For complex pricing structures, the line item can be broken down further in * `sub_line_items`. */ - @JsonProperty("sub_line_items") @ExcludeMissing fun _subLineItems() = subLineItems + @JsonProperty("sub_line_items") + @ExcludeMissing + fun _subLineItems(): JsonField> = subLineItems /** The line amount before any line item-specific discounts or minimums. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - @JsonProperty("tax_amounts") @ExcludeMissing fun _taxAmounts() = taxAmounts + @JsonProperty("tax_amounts") + @ExcludeMissing + fun _taxAmounts(): JsonField> = taxAmounts @JsonAnyGetter @ExcludeMissing @@ -4728,22 +5177,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var subLineItems: JsonField> = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var taxAmounts: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var discount: JsonField? = null + private var endDate: JsonField? = null + private var grouping: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var price: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var subLineItems: JsonField>? = null + private var subtotal: JsonField? = null + private var taxAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4761,9 +5210,9 @@ private constructor( price = lineItem.price quantity = lineItem.quantity startDate = lineItem.startDate - subLineItems = lineItem.subLineItems + subLineItems = lineItem.subLineItems.map { it.toMutableList() } subtotal = lineItem.subtotal - taxAmounts = lineItem.taxAmounts + taxAmounts = lineItem.taxAmounts.map { it.toMutableList() } additionalProperties = lineItem.additionalProperties.toMutableMap() } @@ -4779,10 +5228,24 @@ private constructor( /** The final amount after any discounts or minimums. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -4794,40 +5257,289 @@ private constructor( * populated with the key and a value. The `amount` and `subtotal` will be the values * for this particular grouping. */ - fun grouping(grouping: String) = grouping(JsonField.of(grouping)) + fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + + /** + * [DEPRECATED] For configured prices that are split by a grouping key, this will be + * populated with the key and a value. The `amount` and `subtotal` will be the values + * for this particular grouping. + */ + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) /** * [DEPRECATED] For configured prices that are split by a grouping key, this will be * populated with the key and a value. The `amount` and `subtotal` will be the values * for this particular grouping. */ - fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) - - fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) - - fun maximumAmount(maximumAmount: JsonField) = apply { - this.maximumAmount = maximumAmount - } - - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) - - fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) - - fun minimumAmount(minimumAmount: JsonField) = apply { - this.minimumAmount = minimumAmount - } - - /** The name of the price associated with this line item. */ - fun name(name: String) = name(JsonField.of(name)) - - /** The name of the price associated with this line item. */ - fun name(name: JsonField) = apply { this.name = name } + fun grouping(grouping: JsonField) = apply { this.grouping = grouping } + + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) + + fun maximum(maximum: JsonField) = apply { this.maximum = maximum } + + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) + + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) + + fun minimum(minimum: JsonField) = apply { this.minimum = minimum } + + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + + /** The name of the price associated with this line item. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price associated with this line item. */ + fun name(name: JsonField) = apply { this.name = name } + + /** + * The Price resource represents a price that can be billed on a subscription, resulting + * in a charge on an invoice in the form of an invoice line item. Prices take a quantity + * and determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the + * key for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls + * into, where each tier range is defined by an upper and lower bound. For example, the + * first ten units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 + * (i.e. 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 + * units will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a + * percent (the number of basis points to charge), as well as a cap per event to assess. + * For example, this would allow you to assess a fee of 0.25% on every payment you + * process, with a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given + * event depends on the tier range that the billing period falls into. Each tier range + * is defined by an upper bound. For example, after $1.5M of payment volume is reached, + * each individual payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. + * Similar to tiered pricing, the BPS parameters of a given event depends on the tier + * range that it falls into, where each tier range is defined by an upper and lower + * bound. For example, the first few payments may have a 0.8 BPS take-rate and all + * payments after a specific volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. + * In a one-dimensional matrix, the second value is `null`. Every configuration has a + * list of `matrix_values` which give the unit prices for specified property values. In + * a one-dimensional matrix, the matrix values will have `dimension_values` where the + * second value of the pair is null. If an event does not match any of the dimension + * values in the matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow + * unit pricing. They also have an additional parameter `fixed_price_quantity`. If the + * Price represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5057,7 +5769,7 @@ private constructor( * } * ``` */ - fun price(price: Price) = price(JsonField.of(price)) + fun price(price: Optional) = price(price.orElse(null)) /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5289,6 +6001,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -5313,7 +6090,24 @@ private constructor( * `sub_line_items`. */ fun subLineItems(subLineItems: JsonField>) = apply { - this.subLineItems = subLineItems + this.subLineItems = subLineItems.map { it.toMutableList() } + } + + /** + * For complex pricing structures, the line item can be broken down further in + * `sub_line_items`. + */ + fun addSubLineItem(subLineItem: SubLineItem) = apply { + subLineItems = + (subLineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(subLineItem) + } } /** The line amount before any line item-specific discounts or minimums. */ @@ -5333,7 +6127,24 @@ private constructor( * configured. */ fun taxAmounts(taxAmounts: JsonField>) = apply { - this.taxAmounts = taxAmounts + this.taxAmounts = taxAmounts.map { it.toMutableList() } + } + + /** + * An array of tax rates and their incurred tax amounts. Empty if no tax integration is + * configured. + */ + fun addTaxAmount(taxAmount: TaxAmount) = apply { + taxAmounts = + (taxAmounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(taxAmount) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -5357,22 +6168,24 @@ private constructor( fun build(): LineItem = LineItem( - id, - amount, - discount, - endDate, - grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, - name, - price, - quantity, - startDate, - subLineItems.map { it.toImmutable() }, - subtotal, - taxAmounts.map { it.toImmutable() }, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(subLineItems) { "`subLineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(taxAmounts) { "`taxAmounts` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -5407,10 +6220,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -5435,13 +6250,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -5458,7 +6273,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -5494,8 +6326,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5548,10 +6385,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -5576,13 +6415,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -5599,7 +6438,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -5635,8 +6491,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -5865,17 +6726,23 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("matrix_config") @ExcludeMissing fun _matrixConfig() = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -5904,12 +6771,12 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var matrixConfig: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var matrixConfig: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5929,7 +6796,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -5976,12 +6845,14 @@ private constructor( fun build(): MatrixSubLineItem = MatrixSubLineItem( - amount, - grouping, - matrixConfig, - name, - quantity, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(matrixConfig) { + "`matrixConfig` is required but was not set" + }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6005,10 +6876,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -6033,8 +6904,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6050,7 +6921,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -6079,8 +6953,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6121,7 +6995,7 @@ private constructor( /** The ordered dimension values for this line item. */ @JsonProperty("dimension_values") @ExcludeMissing - fun _dimensionValues() = dimensionValues + fun _dimensionValues(): JsonField> = dimensionValues @JsonAnyGetter @ExcludeMissing @@ -6145,13 +7019,14 @@ private constructor( class Builder { - private var dimensionValues: JsonField> = JsonMissing.of() + private var dimensionValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { - dimensionValues = matrixConfig.dimensionValues + dimensionValues = + matrixConfig.dimensionValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -6161,7 +7036,21 @@ private constructor( /** The ordered dimension values for this line item. */ fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** The ordered dimension values for this line item. */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -6188,7 +7077,10 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensionValues.map { it.toImmutable() }, + checkNotNull(dimensionValues) { + "`dimensionValues` is required but was not set" + } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -6322,17 +7214,23 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("tier_config") @ExcludeMissing fun _tierConfig() = tierConfig + @JsonProperty("tier_config") + @ExcludeMissing + fun _tierConfig(): JsonField = tierConfig - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -6361,12 +7259,12 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var tierConfig: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var tierConfig: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6386,7 +7284,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -6432,12 +7332,12 @@ private constructor( fun build(): TierSubLineItem = TierSubLineItem( - amount, - grouping, - name, - quantity, - tierConfig, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(tierConfig) { "`tierConfig` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6461,10 +7361,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -6489,8 +7389,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6506,7 +7406,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -6535,8 +7438,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6583,11 +7486,17 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") - @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit() = firstUnit + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit - @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit() = lastUnit + @JsonProperty("last_unit") + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing @@ -6613,9 +7522,9 @@ private constructor( class Builder { - private var firstUnit: JsonField = JsonMissing.of() - private var lastUnit: JsonField = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var firstUnit: JsonField? = null + private var lastUnit: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6633,7 +7542,15 @@ private constructor( this.firstUnit = firstUnit } - fun lastUnit(lastUnit: Double) = lastUnit(JsonField.of(lastUnit)) + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) + + fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) + + @Suppress( + "USELESS_CAST" + ) // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lastUnit(lastUnit: Optional) = + lastUnit(lastUnit.orElse(null) as Double?) fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit @@ -6669,9 +7586,13 @@ private constructor( fun build(): TierConfig = TierConfig( - firstUnit, - lastUnit, - unitAmount, + checkNotNull(firstUnit) { + "`firstUnit` is required but was not set" + }, + checkNotNull(lastUnit) { "`lastUnit` is required but was not set" }, + checkNotNull(unitAmount) { + "`unitAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -6800,15 +7721,19 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -6836,11 +7761,11 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6859,7 +7784,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -6899,11 +7826,11 @@ private constructor( fun build(): OtherSubLineItem = OtherSubLineItem( - amount, - grouping, - name, - quantity, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6927,10 +7854,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -6955,8 +7882,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6972,7 +7899,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -7001,8 +7931,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7125,17 +8055,17 @@ private constructor( Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The human-readable description of the applied tax rate. */ @JsonProperty("tax_rate_description") @ExcludeMissing - fun _taxRateDescription() = taxRateDescription + fun _taxRateDescription(): JsonField = taxRateDescription /** The tax rate percentage, out of 100. */ @JsonProperty("tax_rate_percentage") @ExcludeMissing - fun _taxRatePercentage() = taxRatePercentage + fun _taxRatePercentage(): JsonField = taxRatePercentage @JsonAnyGetter @ExcludeMissing @@ -7161,9 +8091,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var taxRateDescription: JsonField = JsonMissing.of() - private var taxRatePercentage: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var taxRateDescription: JsonField? = null + private var taxRatePercentage: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7190,8 +8120,12 @@ private constructor( } /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String) = - taxRatePercentage(JsonField.of(taxRatePercentage)) + fun taxRatePercentage(taxRatePercentage: String?) = + taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: Optional) = + taxRatePercentage(taxRatePercentage.orElse(null)) /** The tax rate percentage, out of 100. */ fun taxRatePercentage(taxRatePercentage: JsonField) = apply { @@ -7222,9 +8156,13 @@ private constructor( fun build(): TaxAmount = TaxAmount( - amount, - taxRateDescription, - taxRatePercentage, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(taxRateDescription) { + "`taxRateDescription` is required but was not set" + }, + checkNotNull(taxRatePercentage) { + "`taxRatePercentage` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -7295,10 +8233,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -7323,13 +8263,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -7346,7 +8286,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -7378,8 +8335,11 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7512,10 +8472,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -7540,13 +8502,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -7563,7 +8525,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -7595,8 +8574,11 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7664,24 +8646,28 @@ private constructor( fun succeeded(): Boolean = succeeded.getRequired("succeeded") /** The ID of the payment attempt. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The amount of the payment attempt. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The time at which the payment attempt was created. */ - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** The payment provider that attempted to collect the payment. */ - @JsonProperty("payment_provider") @ExcludeMissing fun _paymentProvider() = paymentProvider + @JsonProperty("payment_provider") + @ExcludeMissing + fun _paymentProvider(): JsonField = paymentProvider /** The ID of the payment attempt in the payment provider. */ @JsonProperty("payment_provider_id") @ExcludeMissing - fun _paymentProviderId() = paymentProviderId + fun _paymentProviderId(): JsonField = paymentProviderId /** Whether the payment attempt succeeded. */ - @JsonProperty("succeeded") @ExcludeMissing fun _succeeded() = succeeded + @JsonProperty("succeeded") @ExcludeMissing fun _succeeded(): JsonField = succeeded @JsonAnyGetter @ExcludeMissing @@ -7710,12 +8696,12 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var paymentProvider: JsonField = JsonMissing.of() - private var paymentProviderId: JsonField = JsonMissing.of() - private var succeeded: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var createdAt: JsonField? = null + private var paymentProvider: JsonField? = null + private var paymentProviderId: JsonField? = null + private var succeeded: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7750,8 +8736,12 @@ private constructor( } /** The payment provider that attempted to collect the payment. */ - fun paymentProvider(paymentProvider: PaymentProvider) = - paymentProvider(JsonField.of(paymentProvider)) + fun paymentProvider(paymentProvider: PaymentProvider?) = + paymentProvider(JsonField.ofNullable(paymentProvider)) + + /** The payment provider that attempted to collect the payment. */ + fun paymentProvider(paymentProvider: Optional) = + paymentProvider(paymentProvider.orElse(null)) /** The payment provider that attempted to collect the payment. */ fun paymentProvider(paymentProvider: JsonField) = apply { @@ -7759,8 +8749,12 @@ private constructor( } /** The ID of the payment attempt in the payment provider. */ - fun paymentProviderId(paymentProviderId: String) = - paymentProviderId(JsonField.of(paymentProviderId)) + fun paymentProviderId(paymentProviderId: String?) = + paymentProviderId(JsonField.ofNullable(paymentProviderId)) + + /** The ID of the payment attempt in the payment provider. */ + fun paymentProviderId(paymentProviderId: Optional) = + paymentProviderId(paymentProviderId.orElse(null)) /** The ID of the payment attempt in the payment provider. */ fun paymentProviderId(paymentProviderId: JsonField) = apply { @@ -7794,12 +8788,16 @@ private constructor( fun build(): PaymentAttempt = PaymentAttempt( - id, - amount, - createdAt, - paymentProvider, - paymentProviderId, - succeeded, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(paymentProvider) { + "`paymentProvider` is required but was not set" + }, + checkNotNull(paymentProviderId) { + "`paymentProviderId` is required but was not set" + }, + checkNotNull(succeeded) { "`succeeded` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7912,17 +8910,19 @@ private constructor( fun state(): Optional = Optional.ofNullable(state.getNullable("state")) - @JsonProperty("city") @ExcludeMissing fun _city() = city + @JsonProperty("city") @ExcludeMissing fun _city(): JsonField = city - @JsonProperty("country") @ExcludeMissing fun _country() = country + @JsonProperty("country") @ExcludeMissing fun _country(): JsonField = country - @JsonProperty("line1") @ExcludeMissing fun _line1() = line1 + @JsonProperty("line1") @ExcludeMissing fun _line1(): JsonField = line1 - @JsonProperty("line2") @ExcludeMissing fun _line2() = line2 + @JsonProperty("line2") @ExcludeMissing fun _line2(): JsonField = line2 - @JsonProperty("postal_code") @ExcludeMissing fun _postalCode() = postalCode + @JsonProperty("postal_code") + @ExcludeMissing + fun _postalCode(): JsonField = postalCode - @JsonProperty("state") @ExcludeMissing fun _state() = state + @JsonProperty("state") @ExcludeMissing fun _state(): JsonField = state @JsonAnyGetter @ExcludeMissing @@ -7951,12 +8951,12 @@ private constructor( class Builder { - private var city: JsonField = JsonMissing.of() - private var country: JsonField = JsonMissing.of() - private var line1: JsonField = JsonMissing.of() - private var line2: JsonField = JsonMissing.of() - private var postalCode: JsonField = JsonMissing.of() - private var state: JsonField = JsonMissing.of() + private var city: JsonField? = null + private var country: JsonField? = null + private var line1: JsonField? = null + private var line2: JsonField? = null + private var postalCode: JsonField? = null + private var state: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7970,27 +8970,39 @@ private constructor( additionalProperties = shippingAddress.additionalProperties.toMutableMap() } - fun city(city: String) = city(JsonField.of(city)) + fun city(city: String?) = city(JsonField.ofNullable(city)) + + fun city(city: Optional) = city(city.orElse(null)) fun city(city: JsonField) = apply { this.city = city } - fun country(country: String) = country(JsonField.of(country)) + fun country(country: String?) = country(JsonField.ofNullable(country)) + + fun country(country: Optional) = country(country.orElse(null)) fun country(country: JsonField) = apply { this.country = country } - fun line1(line1: String) = line1(JsonField.of(line1)) + fun line1(line1: String?) = line1(JsonField.ofNullable(line1)) + + fun line1(line1: Optional) = line1(line1.orElse(null)) fun line1(line1: JsonField) = apply { this.line1 = line1 } - fun line2(line2: String) = line2(JsonField.of(line2)) + fun line2(line2: String?) = line2(JsonField.ofNullable(line2)) + + fun line2(line2: Optional) = line2(line2.orElse(null)) fun line2(line2: JsonField) = apply { this.line2 = line2 } - fun postalCode(postalCode: String) = postalCode(JsonField.of(postalCode)) + fun postalCode(postalCode: String?) = postalCode(JsonField.ofNullable(postalCode)) + + fun postalCode(postalCode: Optional) = postalCode(postalCode.orElse(null)) fun postalCode(postalCode: JsonField) = apply { this.postalCode = postalCode } - fun state(state: String) = state(JsonField.of(state)) + fun state(state: String?) = state(JsonField.ofNullable(state)) + + fun state(state: Optional) = state(state.orElse(null)) fun state(state: JsonField) = apply { this.state = state } @@ -8015,12 +9027,12 @@ private constructor( fun build(): ShippingAddress = ShippingAddress( - city, - country, - line1, - line2, - postalCode, - state, + checkNotNull(city) { "`city` is required but was not set" }, + checkNotNull(country) { "`country` is required but was not set" }, + checkNotNull(line1) { "`line1` is required but was not set" }, + checkNotNull(line2) { "`line2` is required but was not set" }, + checkNotNull(postalCode) { "`postalCode` is required but was not set" }, + checkNotNull(state) { "`state` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -8129,7 +9141,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -8153,7 +9165,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8185,7 +9197,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): Subscription = Subscription(id, additionalProperties.toImmutable()) + fun build(): Subscription = + Subscription( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt index 7d0e65cf..f6695566 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceIssueParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,13 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows an eligible invoice to be issued manually. This is only possible with + * invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` is a + * time in the past. Issuing an invoice could possibly trigger side effects, some of which could be + * customer-visible (e.g. sending emails, auto-collecting payment, syncing the invoice to external + * providers, etc). + */ class InvoiceIssueParams constructor( private val invoiceId: String, @@ -34,12 +43,20 @@ constructor( */ fun synchronous(): Optional = body.synchronous() + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices containin no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + */ + fun _synchronous(): JsonField = body._synchronous() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): InvoiceIssueBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -57,11 +74,22 @@ constructor( class InvoiceIssueBody @JsonCreator internal constructor( - @JsonProperty("synchronous") private val synchronous: Boolean?, + @JsonProperty("synchronous") + @ExcludeMissing + private val synchronous: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * If true, the invoice will be issued synchronously. If false, the invoice will be issued + * asynchronously. The synchronous option is only available for invoices containin no usage + * fees. If the invoice is configured to sync to an external provider, a successful response + * from this endpoint guarantees the invoice is present in the provider. + */ + fun synchronous(): Optional = + Optional.ofNullable(synchronous.getNullable("synchronous")) + /** * If true, the invoice will be issued synchronously. If false, the invoice will be issued * asynchronously. The synchronous option is only available for invoices containin no usage @@ -69,12 +97,22 @@ constructor( * from this endpoint guarantees the invoice is present in the provider. */ @JsonProperty("synchronous") - fun synchronous(): Optional = Optional.ofNullable(synchronous) + @ExcludeMissing + fun _synchronous(): JsonField = synchronous @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceIssueBody = apply { + if (!validated) { + synchronous() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -84,7 +122,7 @@ constructor( class Builder { - private var synchronous: Boolean? = null + private var synchronous: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -100,7 +138,7 @@ constructor( * provider, a successful response from this endpoint guarantees the invoice is present * in the provider. */ - fun synchronous(synchronous: Boolean?) = apply { this.synchronous = synchronous } + fun synchronous(synchronous: Boolean) = synchronous(JsonField.of(synchronous)) /** * If true, the invoice will be issued synchronously. If false, the invoice will be @@ -109,18 +147,9 @@ constructor( * provider, a successful response from this endpoint guarantees the invoice is present * in the provider. */ - fun synchronous(synchronous: Boolean) = synchronous(synchronous as Boolean?) - - /** - * If true, the invoice will be issued synchronously. If false, the invoice will be - * issued asynchronously. The synchronous option is only available for invoices - * containin no usage fees. If the invoice is configured to sync to an external - * provider, a successful response from this endpoint guarantees the invoice is present - * in the provider. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun synchronous(synchronous: Optional) = - synchronous(synchronous.orElse(null) as Boolean?) + fun synchronous(synchronous: JsonField) = apply { + this.synchronous = synchronous + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -194,7 +223,7 @@ constructor( * fees. If the invoice is configured to sync to an external provider, a successful response * from this endpoint guarantees the invoice is present in the provider. */ - fun synchronous(synchronous: Boolean?) = apply { body.synchronous(synchronous) } + fun synchronous(synchronous: Boolean) = apply { body.synchronous(synchronous) } /** * If true, the invoice will be issued synchronously. If false, the invoice will be issued @@ -202,17 +231,26 @@ constructor( * fees. If the invoice is configured to sync to an external provider, a successful response * from this endpoint guarantees the invoice is present in the provider. */ - fun synchronous(synchronous: Boolean) = synchronous(synchronous as Boolean?) + fun synchronous(synchronous: JsonField) = apply { body.synchronous(synchronous) } - /** - * If true, the invoice will be issued synchronously. If false, the invoice will be issued - * asynchronously. The synchronous option is only available for invoices containin no usage - * fees. If the invoice is configured to sync to an external provider, a successful response - * from this endpoint guarantees the invoice is present in the provider. - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun synchronous(synchronous: Optional) = - synchronous(synchronous.orElse(null) as Boolean?) + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -312,25 +350,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): InvoiceIssueParams = InvoiceIssueParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt index a1975bec..c6accbed 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,10 @@ import com.withorb.api.core.toImmutable import java.time.LocalDate import java.util.Objects +/** + * This creates a one-off fixed fee invoice line item on an Invoice. This can only be done for + * invoices that are in a `draft` status. + */ class InvoiceLineItemCreateParams constructor( private val body: InvoiceLineItemCreateBody, @@ -44,12 +50,33 @@ constructor( /** A date string to specify the line item's start date in the customer's timezone. */ fun startDate(): LocalDate = body.startDate() - fun _additionalHeaders(): Headers = additionalHeaders + /** The total amount in the invoice's currency to add to the line item. */ + fun _amount(): JsonField = body._amount() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** A date string to specify the line item's end date in the customer's timezone. */ + fun _endDate(): JsonField = body._endDate() + + /** The id of the Invoice to add this line item. */ + fun _invoiceId(): JsonField = body._invoiceId() + + /** + * The item name associated with this line item. If an item with the same name exists in Orb, + * that item will be associated with the line item. + */ + fun _name(): JsonField = body._name() + + /** The number of units on the line item */ + fun _quantity(): JsonField = body._quantity() + + /** A date string to specify the line item's start date in the customer's timezone. */ + fun _startDate(): JsonField = body._startDate() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): InvoiceLineItemCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -60,41 +87,90 @@ constructor( class InvoiceLineItemCreateBody @JsonCreator internal constructor( - @JsonProperty("amount") private val amount: String, - @JsonProperty("end_date") private val endDate: LocalDate, - @JsonProperty("invoice_id") private val invoiceId: String, - @JsonProperty("name") private val name: String, - @JsonProperty("quantity") private val quantity: Double, - @JsonProperty("start_date") private val startDate: LocalDate, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("invoice_id") + @ExcludeMissing + private val invoiceId: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The total amount in the invoice's currency to add to the line item. */ - @JsonProperty("amount") fun amount(): String = amount + fun amount(): String = amount.getRequired("amount") + + /** A date string to specify the line item's end date in the customer's timezone. */ + fun endDate(): LocalDate = endDate.getRequired("end_date") + + /** The id of the Invoice to add this line item. */ + fun invoiceId(): String = invoiceId.getRequired("invoice_id") + + /** + * The item name associated with this line item. If an item with the same name exists in + * Orb, that item will be associated with the line item. + */ + fun name(): String = name.getRequired("name") + + /** The number of units on the line item */ + fun quantity(): Double = quantity.getRequired("quantity") + + /** A date string to specify the line item's start date in the customer's timezone. */ + fun startDate(): LocalDate = startDate.getRequired("start_date") + + /** The total amount in the invoice's currency to add to the line item. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** A date string to specify the line item's end date in the customer's timezone. */ - @JsonProperty("end_date") fun endDate(): LocalDate = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** The id of the Invoice to add this line item. */ - @JsonProperty("invoice_id") fun invoiceId(): String = invoiceId + @JsonProperty("invoice_id") @ExcludeMissing fun _invoiceId(): JsonField = invoiceId /** * The item name associated with this line item. If an item with the same name exists in * Orb, that item will be associated with the line item. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The number of units on the line item */ - @JsonProperty("quantity") fun quantity(): Double = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** A date string to specify the line item's start date in the customer's timezone. */ - @JsonProperty("start_date") fun startDate(): LocalDate = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceLineItemCreateBody = apply { + if (!validated) { + amount() + endDate() + invoiceId() + name() + quantity() + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -104,12 +180,12 @@ constructor( class Builder { - private var amount: String? = null - private var endDate: LocalDate? = null - private var invoiceId: String? = null - private var name: String? = null - private var quantity: Double? = null - private var startDate: LocalDate? = null + private var amount: JsonField? = null + private var endDate: JsonField? = null + private var invoiceId: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -124,25 +200,46 @@ constructor( } /** The total amount in the invoice's currency to add to the line item. */ - fun amount(amount: String) = apply { this.amount = amount } + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** The total amount in the invoice's currency to add to the line item. */ + fun amount(amount: JsonField) = apply { this.amount = amount } /** A date string to specify the line item's end date in the customer's timezone. */ - fun endDate(endDate: LocalDate) = apply { this.endDate = endDate } + fun endDate(endDate: LocalDate) = endDate(JsonField.of(endDate)) + + /** A date string to specify the line item's end date in the customer's timezone. */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + /** The id of the Invoice to add this line item. */ + fun invoiceId(invoiceId: String) = invoiceId(JsonField.of(invoiceId)) /** The id of the Invoice to add this line item. */ - fun invoiceId(invoiceId: String) = apply { this.invoiceId = invoiceId } + fun invoiceId(invoiceId: JsonField) = apply { this.invoiceId = invoiceId } /** * The item name associated with this line item. If an item with the same name exists in * Orb, that item will be associated with the line item. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** + * The item name associated with this line item. If an item with the same name exists in + * Orb, that item will be associated with the line item. + */ + fun name(name: JsonField) = apply { this.name = name } + + /** The number of units on the line item */ + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) /** The number of units on the line item */ - fun quantity(quantity: Double) = apply { this.quantity = quantity } + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } + + /** A date string to specify the line item's start date in the customer's timezone. */ + fun startDate(startDate: LocalDate) = startDate(JsonField.of(startDate)) /** A date string to specify the line item's start date in the customer's timezone. */ - fun startDate(startDate: LocalDate) = apply { this.startDate = startDate } + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -217,24 +314,64 @@ constructor( /** The total amount in the invoice's currency to add to the line item. */ fun amount(amount: String) = apply { body.amount(amount) } + /** The total amount in the invoice's currency to add to the line item. */ + fun amount(amount: JsonField) = apply { body.amount(amount) } + /** A date string to specify the line item's end date in the customer's timezone. */ fun endDate(endDate: LocalDate) = apply { body.endDate(endDate) } + /** A date string to specify the line item's end date in the customer's timezone. */ + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + /** The id of the Invoice to add this line item. */ fun invoiceId(invoiceId: String) = apply { body.invoiceId(invoiceId) } + /** The id of the Invoice to add this line item. */ + fun invoiceId(invoiceId: JsonField) = apply { body.invoiceId(invoiceId) } + /** * The item name associated with this line item. If an item with the same name exists in * Orb, that item will be associated with the line item. */ fun name(name: String) = apply { body.name(name) } + /** + * The item name associated with this line item. If an item with the same name exists in + * Orb, that item will be associated with the line item. + */ + fun name(name: JsonField) = apply { body.name(name) } + /** The number of units on the line item */ fun quantity(quantity: Double) = apply { body.quantity(quantity) } + /** The number of units on the line item */ + fun quantity(quantity: JsonField) = apply { body.quantity(quantity) } + /** A date string to specify the line item's start date in the customer's timezone. */ fun startDate(startDate: LocalDate) = apply { body.startDate(startDate) } + /** A date string to specify the line item's start date in the customer's timezone. */ + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -333,25 +470,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): InvoiceLineItemCreateParams = InvoiceLineItemCreateParams( body.build(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt index be7809ee..de0059e2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceLineItemCreateResponse.kt @@ -360,33 +360,37 @@ private constructor( fun taxAmounts(): List = taxAmounts.getRequired("tax_amounts") /** A unique ID for this line item. */ - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The final amount after any discounts or minimums. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** The end date of the range of time applied for this line item's price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** * [DEPRECATED] For configured prices that are split by a grouping key, this will be populated * with the key and a value. The `amount` and `subtotal` will be the values for this particular * grouping. */ - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") @ExcludeMissing fun _grouping(): JsonField = grouping - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The name of the price associated with this line item. */ - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The Price resource represents a price that can be billed on a subscription, resulting in a @@ -616,26 +620,32 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** The start date of the range of time applied for this line item's price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * For complex pricing structures, the line item can be broken down further in `sub_line_items`. */ - @JsonProperty("sub_line_items") @ExcludeMissing fun _subLineItems() = subLineItems + @JsonProperty("sub_line_items") + @ExcludeMissing + fun _subLineItems(): JsonField> = subLineItems /** The line amount before any line item-specific discounts or minimums. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** * An array of tax rates and their incurred tax amounts. Empty if no tax integration is * configured. */ - @JsonProperty("tax_amounts") @ExcludeMissing fun _taxAmounts() = taxAmounts + @JsonProperty("tax_amounts") + @ExcludeMissing + fun _taxAmounts(): JsonField> = taxAmounts @JsonAnyGetter @ExcludeMissing @@ -674,22 +684,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var amount: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var subLineItems: JsonField> = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var taxAmounts: JsonField> = JsonMissing.of() + private var id: JsonField? = null + private var amount: JsonField? = null + private var discount: JsonField? = null + private var endDate: JsonField? = null + private var grouping: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var price: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null + private var subLineItems: JsonField>? = null + private var subtotal: JsonField? = null + private var taxAmounts: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -707,9 +717,9 @@ private constructor( price = invoiceLineItemCreateResponse.price quantity = invoiceLineItemCreateResponse.quantity startDate = invoiceLineItemCreateResponse.startDate - subLineItems = invoiceLineItemCreateResponse.subLineItems + subLineItems = invoiceLineItemCreateResponse.subLineItems.map { it.toMutableList() } subtotal = invoiceLineItemCreateResponse.subtotal - taxAmounts = invoiceLineItemCreateResponse.taxAmounts + taxAmounts = invoiceLineItemCreateResponse.taxAmounts.map { it.toMutableList() } additionalProperties = invoiceLineItemCreateResponse.additionalProperties.toMutableMap() } @@ -725,10 +735,24 @@ private constructor( /** The final amount after any discounts or minimums. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + /** The end date of the range of time applied for this line item's price. */ fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) @@ -740,7 +764,14 @@ private constructor( * populated with the key and a value. The `amount` and `subtotal` will be the values for * this particular grouping. */ - fun grouping(grouping: String) = grouping(JsonField.of(grouping)) + fun grouping(grouping: String?) = grouping(JsonField.ofNullable(grouping)) + + /** + * [DEPRECATED] For configured prices that are split by a grouping key, this will be + * populated with the key and a value. The `amount` and `subtotal` will be the values for + * this particular grouping. + */ + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) /** * [DEPRECATED] For configured prices that are split by a grouping key, this will be @@ -749,21 +780,33 @@ private constructor( */ fun grouping(grouping: JsonField) = apply { this.grouping = grouping } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -1003,7 +1046,237 @@ private constructor( * } * ``` */ - fun price(price: Price) = price(JsonField.of(price)) + fun price(price: Price?) = price(JsonField.ofNullable(price)) + + /** + * The Price resource represents a price that can be billed on a subscription, resulting in + * a charge on an invoice in the form of an invoice line item. Prices take a quantity and + * determine an amount to bill. + * + * Orb supports a few different pricing models out of the box. Each of these models is + * serialized differently in a given Price object. The model_type field determines the key + * for the configuration object that is present. + * + * ## Unit pricing + * + * With unit pricing, each unit costs a fixed amount. + * + * ```json + * { + * ... + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * } + * ... + * } + * ``` + * + * ## Tiered pricing + * + * In tiered pricing, the cost of a given unit depends on the tier range that it falls into, + * where each tier range is defined by an upper and lower bound. For example, the first ten + * units may cost $0.50 each and all units thereafter may cost $0.10 each. + * + * ```json + * { + * ... + * "model_type": "tiered", + * "tiered_config": { + * "tiers": [ + * { + * "first_unit": 1, + * "last_unit": 10, + * "unit_amount": "0.50" + * }, + * { + * "first_unit": 11, + * "last_unit": null, + * "unit_amount": "0.10" + * } + * ] + * } + * ... + * ``` + * + * ## Bulk pricing + * + * Bulk pricing applies when the number of units determine the cost of all units. For + * example, if you've bought less than 10 units, they may each be $0.50 for a total of + * $5.00. Once you've bought more than 10 units, all units may now be priced at $0.40 (i.e. + * 101 units total would be $40.40). + * + * ```json + * { + * ... + * "model_type": "bulk", + * "bulk_config": { + * "tiers": [ + * { + * "maximum_units": 10, + * "unit_amount": "0.50" + * }, + * { + * "maximum_units": 1000, + * "unit_amount": "0.40" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Package pricing + * + * Package pricing defines the size or granularity of a unit for billing purposes. For + * example, if the package size is set to 5, then 4 units will be billed as 5 and 6 units + * will be billed at 10. + * + * ```json + * { + * ... + * "model_type": "package", + * "package_config": { + * "package_amount": "0.80", + * "package_size": 10 + * } + * ... + * } + * ``` + * + * ## BPS pricing + * + * BPS pricing specifies a per-event (e.g. per-payment) rate in one hundredth of a percent + * (the number of basis points to charge), as well as a cap per event to assess. For + * example, this would allow you to assess a fee of 0.25% on every payment you process, with + * a maximum charge of $25 per payment. + * + * ```json + * { + * ... + * "model_type": "bps", + * "bps_config": { + * "bps": 125, + * "per_unit_maximum": "11.00" + * } + * ... + * } + * ``` + * + * ## Bulk BPS pricing + * + * Bulk BPS pricing specifies BPS parameters in a tiered manner, dependent on the total + * quantity across all events. Similar to bulk pricing, the BPS parameters of a given event + * depends on the tier range that the billing period falls into. Each tier range is defined + * by an upper bound. For example, after $1.5M of payment volume is reached, each individual + * payment may have a lower cap or a smaller take-rate. + * + * ```json + * ... + * "model_type": "bulk_bps", + * "bulk_bps_config": { + * "tiers": [ + * { + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Tiered BPS pricing + * + * Tiered BPS pricing specifies BPS parameters in a graduated manner, where an event's + * applicable parameter is a function of its marginal addition to the period total. Similar + * to tiered pricing, the BPS parameters of a given event depends on the tier range that it + * falls into, where each tier range is defined by an upper and lower bound. For example, + * the first few payments may have a 0.8 BPS take-rate and all payments after a specific + * volume may incur a take-rate of 0.5 BPS each. + * + * ```json + * ... + * "model_type": "tiered_bps", + * "tiered_bps_config": { + * "tiers": [ + * { + * "minimum_amount": "0", + * "maximum_amount": "1000000.00", + * "bps": 125, + * "per_unit_maximum": "19.00" + * }, + * { + * "minimum_amount": "1000000.00", + * "maximum_amount": null, + * "bps": 115, + * "per_unit_maximum": "4.00" + * } + * ] + * } + * ... + * } + * ``` + * + * ## Matrix pricing + * + * Matrix pricing defines a set of unit prices in a one or two-dimensional matrix. + * `dimensions` defines the two event property values evaluated in this pricing model. In a + * one-dimensional matrix, the second value is `null`. Every configuration has a list of + * `matrix_values` which give the unit prices for specified property values. In a + * one-dimensional matrix, the matrix values will have `dimension_values` where the second + * value of the pair is null. If an event does not match any of the dimension values in the + * matrix, it will resort to the `default_unit_amount`. + * + * ```json + * { + * "model_type": "matrix" + * "matrix_config": { + * "default_unit_amount": "3.00", + * "dimensions": [ + * "cluster_name", + * "region" + * ], + * "matrix_values": [ + * { + * "dimension_values": [ + * "alpha", + * "west" + * ], + * "unit_amount": "2.00" + * }, + * ... + * ] + * } + * } + * ``` + * + * ## Fixed fees + * + * Fixed fees are prices that are applied independent of usage quantities, and follow unit + * pricing. They also have an additional parameter `fixed_price_quantity`. If the Price + * represents a fixed cost, this represents the quantity of units applied. + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "2.00" + * }, + * "fixed_price_quantity": 3.0 + * ... + * } + * ``` + */ + fun price(price: Optional) = price(price.orElse(null)) /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -1235,6 +1508,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -1256,7 +1594,24 @@ private constructor( * `sub_line_items`. */ fun subLineItems(subLineItems: JsonField>) = apply { - this.subLineItems = subLineItems + this.subLineItems = subLineItems.map { it.toMutableList() } + } + + /** + * For complex pricing structures, the line item can be broken down further in + * `sub_line_items`. + */ + fun addSubLineItem(subLineItem: SubLineItem) = apply { + subLineItems = + (subLineItems ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(subLineItem) + } } /** The line amount before any line item-specific discounts or minimums. */ @@ -1276,7 +1631,24 @@ private constructor( * configured. */ fun taxAmounts(taxAmounts: JsonField>) = apply { - this.taxAmounts = taxAmounts + this.taxAmounts = taxAmounts.map { it.toMutableList() } + } + + /** + * An array of tax rates and their incurred tax amounts. Empty if no tax integration is + * configured. + */ + fun addTaxAmount(taxAmount: TaxAmount) = apply { + taxAmounts = + (taxAmounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(taxAmount) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -1300,22 +1672,24 @@ private constructor( fun build(): InvoiceLineItemCreateResponse = InvoiceLineItemCreateResponse( - id, - amount, - discount, - endDate, - grouping, - maximum, - maximumAmount, - minimum, - minimumAmount, - name, - price, - quantity, - startDate, - subLineItems.map { it.toImmutable() }, - subtotal, - taxAmounts.map { it.toImmutable() }, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(subLineItems) { "`subLineItems` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(taxAmounts) { "`taxAmounts` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -1350,10 +1724,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -1378,13 +1754,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -1401,7 +1777,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -1433,8 +1826,11 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1487,10 +1883,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -1515,13 +1913,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -1538,7 +1936,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -1570,8 +1985,11 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1788,17 +2206,21 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("matrix_config") @ExcludeMissing fun _matrixConfig() = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -1827,12 +2249,12 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var matrixConfig: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var matrixConfig: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1852,7 +2274,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -1899,12 +2323,12 @@ private constructor( fun build(): MatrixSubLineItem = MatrixSubLineItem( - amount, - grouping, - matrixConfig, - name, - quantity, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(matrixConfig) { "`matrixConfig` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1928,10 +2352,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -1956,8 +2380,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1972,7 +2396,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -2001,8 +2428,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2043,7 +2470,7 @@ private constructor( /** The ordered dimension values for this line item. */ @JsonProperty("dimension_values") @ExcludeMissing - fun _dimensionValues() = dimensionValues + fun _dimensionValues(): JsonField> = dimensionValues @JsonAnyGetter @ExcludeMissing @@ -2067,12 +2494,12 @@ private constructor( class Builder { - private var dimensionValues: JsonField> = JsonMissing.of() + private var dimensionValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { - dimensionValues = matrixConfig.dimensionValues + dimensionValues = matrixConfig.dimensionValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -2082,7 +2509,21 @@ private constructor( /** The ordered dimension values for this line item. */ fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** The ordered dimension values for this line item. */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -2109,7 +2550,10 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - dimensionValues.map { it.toImmutable() }, + checkNotNull(dimensionValues) { + "`dimensionValues` is required but was not set" + } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -2242,17 +2686,21 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("tier_config") @ExcludeMissing fun _tierConfig() = tierConfig + @JsonProperty("tier_config") + @ExcludeMissing + fun _tierConfig(): JsonField = tierConfig - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2281,12 +2729,12 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var tierConfig: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var tierConfig: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2306,7 +2754,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -2352,12 +2802,12 @@ private constructor( fun build(): TierSubLineItem = TierSubLineItem( - amount, - grouping, - name, - quantity, - tierConfig, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(tierConfig) { "`tierConfig` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2381,10 +2831,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -2409,8 +2859,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2425,7 +2875,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -2454,8 +2907,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2502,11 +2955,17 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") - @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit() = firstUnit + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit - @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit() = lastUnit + @JsonProperty("last_unit") + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing @@ -2532,9 +2991,9 @@ private constructor( class Builder { - private var firstUnit: JsonField = JsonMissing.of() - private var lastUnit: JsonField = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var firstUnit: JsonField? = null + private var lastUnit: JsonField? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2551,7 +3010,13 @@ private constructor( this.firstUnit = firstUnit } - fun lastUnit(lastUnit: Double) = lastUnit(JsonField.of(lastUnit)) + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) + + fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lastUnit(lastUnit: Optional) = + lastUnit(lastUnit.orElse(null) as Double?) fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } @@ -2585,9 +3050,9 @@ private constructor( fun build(): TierConfig = TierConfig( - firstUnit, - lastUnit, - unitAmount, + checkNotNull(firstUnit) { "`firstUnit` is required but was not set" }, + checkNotNull(lastUnit) { "`lastUnit` is required but was not set" }, + checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2715,15 +3180,17 @@ private constructor( fun type(): Type = type.getRequired("type") /** The total amount for this sub line item. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount - @JsonProperty("grouping") @ExcludeMissing fun _grouping() = grouping + @JsonProperty("grouping") + @ExcludeMissing + fun _grouping(): JsonField = grouping - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("type") @ExcludeMissing fun _type() = type + @JsonProperty("type") @ExcludeMissing fun _type(): JsonField = type @JsonAnyGetter @ExcludeMissing @@ -2751,11 +3218,11 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var grouping: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var type: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var grouping: JsonField? = null + private var name: JsonField? = null + private var quantity: JsonField? = null + private var type: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2774,7 +3241,9 @@ private constructor( /** The total amount for this sub line item. */ fun amount(amount: JsonField) = apply { this.amount = amount } - fun grouping(grouping: Grouping) = grouping(JsonField.of(grouping)) + fun grouping(grouping: Grouping?) = grouping(JsonField.ofNullable(grouping)) + + fun grouping(grouping: Optional) = grouping(grouping.orElse(null)) fun grouping(grouping: JsonField) = apply { this.grouping = grouping } @@ -2814,11 +3283,11 @@ private constructor( fun build(): OtherSubLineItem = OtherSubLineItem( - amount, - grouping, - name, - quantity, - type, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(grouping) { "`grouping` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(type) { "`type` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2842,10 +3311,10 @@ private constructor( /** No value indicates the default group */ fun value(): Optional = Optional.ofNullable(value.getNullable("value")) - @JsonProperty("key") @ExcludeMissing fun _key() = key + @JsonProperty("key") @ExcludeMissing fun _key(): JsonField = key /** No value indicates the default group */ - @JsonProperty("value") @ExcludeMissing fun _value() = value + @JsonProperty("value") @ExcludeMissing fun _value(): JsonField = value @JsonAnyGetter @ExcludeMissing @@ -2870,8 +3339,8 @@ private constructor( class Builder { - private var key: JsonField = JsonMissing.of() - private var value: JsonField = JsonMissing.of() + private var key: JsonField? = null + private var value: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2886,7 +3355,10 @@ private constructor( fun key(key: JsonField) = apply { this.key = key } /** No value indicates the default group */ - fun value(value: String) = value(JsonField.of(value)) + fun value(value: String?) = value(JsonField.ofNullable(value)) + + /** No value indicates the default group */ + fun value(value: Optional) = value(value.orElse(null)) /** No value indicates the default group */ fun value(value: JsonField) = apply { this.value = value } @@ -2915,8 +3387,8 @@ private constructor( fun build(): Grouping = Grouping( - key, - value, + checkNotNull(key) { "`key` is required but was not set" }, + checkNotNull(value) { "`value` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3037,17 +3509,17 @@ private constructor( Optional.ofNullable(taxRatePercentage.getNullable("tax_rate_percentage")) /** The amount of additional tax incurred by this tax rate. */ - @JsonProperty("amount") @ExcludeMissing fun _amount() = amount + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The human-readable description of the applied tax rate. */ @JsonProperty("tax_rate_description") @ExcludeMissing - fun _taxRateDescription() = taxRateDescription + fun _taxRateDescription(): JsonField = taxRateDescription /** The tax rate percentage, out of 100. */ @JsonProperty("tax_rate_percentage") @ExcludeMissing - fun _taxRatePercentage() = taxRatePercentage + fun _taxRatePercentage(): JsonField = taxRatePercentage @JsonAnyGetter @ExcludeMissing @@ -3073,9 +3545,9 @@ private constructor( class Builder { - private var amount: JsonField = JsonMissing.of() - private var taxRateDescription: JsonField = JsonMissing.of() - private var taxRatePercentage: JsonField = JsonMissing.of() + private var amount: JsonField? = null + private var taxRateDescription: JsonField? = null + private var taxRatePercentage: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3102,8 +3574,12 @@ private constructor( } /** The tax rate percentage, out of 100. */ - fun taxRatePercentage(taxRatePercentage: String) = - taxRatePercentage(JsonField.of(taxRatePercentage)) + fun taxRatePercentage(taxRatePercentage: String?) = + taxRatePercentage(JsonField.ofNullable(taxRatePercentage)) + + /** The tax rate percentage, out of 100. */ + fun taxRatePercentage(taxRatePercentage: Optional) = + taxRatePercentage(taxRatePercentage.orElse(null)) /** The tax rate percentage, out of 100. */ fun taxRatePercentage(taxRatePercentage: JsonField) = apply { @@ -3131,9 +3607,13 @@ private constructor( fun build(): TaxAmount = TaxAmount( - amount, - taxRateDescription, - taxRatePercentage, + checkNotNull(amount) { "`amount` is required but was not set" }, + checkNotNull(taxRateDescription) { + "`taxRateDescription` is required but was not set" + }, + checkNotNull(taxRatePercentage) { + "`taxRatePercentage` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt index 225b2d57..044128a5 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceListParams.kt @@ -16,6 +16,20 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all [`Invoice`](../guides/concepts#invoice)s for an account in a + * list format. + * + * The list of invoices is ordered starting from the most recently issued invoice date. The response + * also includes [`pagination_metadata`](../reference/pagination), which lets the caller retrieve + * the next page of results if they exist. + * + * By default, this only returns invoices that are `issued`, `paid`, or `synced`. + * + * When fetching any `draft` invoices, this returns the last-computed invoice values for each draft + * invoice, which may not always be up-to-date since Orb regularly refreshes invoices + * asynchronously. + */ class InvoiceListParams constructor( private val amount: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt index 1b693eaa..f599a942 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceMarkPaidParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,10 @@ import java.time.LocalDate import java.util.Objects import java.util.Optional +/** + * This endpoint allows an invoice's status to be set the `paid` status. This can only be done to + * invoices that are in the `issued` status. + */ class InvoiceMarkPaidParams constructor( private val invoiceId: String, @@ -36,12 +42,21 @@ constructor( /** An optional note to associate with the payment. */ fun notes(): Optional = body.notes() - fun _additionalHeaders(): Headers = additionalHeaders + /** A date string to specify the date of the payment. */ + fun _paymentReceivedDate(): JsonField = body._paymentReceivedDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** An optional external ID to associate with the payment. */ + fun _externalId(): JsonField = body._externalId() + + /** An optional note to associate with the payment. */ + fun _notes(): JsonField = body._notes() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): InvoiceMarkPaidBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -59,28 +74,58 @@ constructor( class InvoiceMarkPaidBody @JsonCreator internal constructor( - @JsonProperty("payment_received_date") private val paymentReceivedDate: LocalDate, - @JsonProperty("external_id") private val externalId: String?, - @JsonProperty("notes") private val notes: String?, + @JsonProperty("payment_received_date") + @ExcludeMissing + private val paymentReceivedDate: JsonField = JsonMissing.of(), + @JsonProperty("external_id") + @ExcludeMissing + private val externalId: JsonField = JsonMissing.of(), + @JsonProperty("notes") + @ExcludeMissing + private val notes: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** A date string to specify the date of the payment. */ + fun paymentReceivedDate(): LocalDate = + paymentReceivedDate.getRequired("payment_received_date") + + /** An optional external ID to associate with the payment. */ + fun externalId(): Optional = + Optional.ofNullable(externalId.getNullable("external_id")) + + /** An optional note to associate with the payment. */ + fun notes(): Optional = Optional.ofNullable(notes.getNullable("notes")) + /** A date string to specify the date of the payment. */ @JsonProperty("payment_received_date") - fun paymentReceivedDate(): LocalDate = paymentReceivedDate + @ExcludeMissing + fun _paymentReceivedDate(): JsonField = paymentReceivedDate /** An optional external ID to associate with the payment. */ @JsonProperty("external_id") - fun externalId(): Optional = Optional.ofNullable(externalId) + @ExcludeMissing + fun _externalId(): JsonField = externalId /** An optional note to associate with the payment. */ - @JsonProperty("notes") fun notes(): Optional = Optional.ofNullable(notes) + @JsonProperty("notes") @ExcludeMissing fun _notes(): JsonField = notes @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceMarkPaidBody = apply { + if (!validated) { + paymentReceivedDate() + externalId() + notes() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -90,9 +135,9 @@ constructor( class Builder { - private var paymentReceivedDate: LocalDate? = null - private var externalId: String? = null - private var notes: String? = null + private var paymentReceivedDate: JsonField? = null + private var externalId: JsonField = JsonMissing.of() + private var notes: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -104,22 +149,32 @@ constructor( } /** A date string to specify the date of the payment. */ - fun paymentReceivedDate(paymentReceivedDate: LocalDate) = apply { + fun paymentReceivedDate(paymentReceivedDate: LocalDate) = + paymentReceivedDate(JsonField.of(paymentReceivedDate)) + + /** A date string to specify the date of the payment. */ + fun paymentReceivedDate(paymentReceivedDate: JsonField) = apply { this.paymentReceivedDate = paymentReceivedDate } /** An optional external ID to associate with the payment. */ - fun externalId(externalId: String?) = apply { this.externalId = externalId } + fun externalId(externalId: String?) = externalId(JsonField.ofNullable(externalId)) /** An optional external ID to associate with the payment. */ fun externalId(externalId: Optional) = externalId(externalId.orElse(null)) + /** An optional external ID to associate with the payment. */ + fun externalId(externalId: JsonField) = apply { this.externalId = externalId } + /** An optional note to associate with the payment. */ - fun notes(notes: String?) = apply { this.notes = notes } + fun notes(notes: String?) = notes(JsonField.ofNullable(notes)) /** An optional note to associate with the payment. */ fun notes(notes: Optional) = notes(notes.orElse(null)) + /** An optional note to associate with the payment. */ + fun notes(notes: JsonField) = apply { this.notes = notes } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -198,18 +253,48 @@ constructor( body.paymentReceivedDate(paymentReceivedDate) } + /** A date string to specify the date of the payment. */ + fun paymentReceivedDate(paymentReceivedDate: JsonField) = apply { + body.paymentReceivedDate(paymentReceivedDate) + } + /** An optional external ID to associate with the payment. */ fun externalId(externalId: String?) = apply { body.externalId(externalId) } /** An optional external ID to associate with the payment. */ fun externalId(externalId: Optional) = externalId(externalId.orElse(null)) + /** An optional external ID to associate with the payment. */ + fun externalId(externalId: JsonField) = apply { body.externalId(externalId) } + /** An optional note to associate with the payment. */ fun notes(notes: String?) = apply { body.notes(notes) } /** An optional note to associate with the payment. */ fun notes(notes: Optional) = notes(notes.orElse(null)) + /** An optional note to associate with the payment. */ + fun notes(notes: JsonField) = apply { body.notes(notes) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -308,25 +393,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): InvoiceMarkPaidParams = InvoiceMarkPaidParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt index d1d9abfd..e5c18a0d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoicePayParams.kt @@ -10,6 +10,10 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint collects payment for an invoice using the customer's default payment method. This + * action can only be taken on invoices with status "issued". + */ class InvoicePayParams constructor( private val invoiceId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt index a927fda1..356da205 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,12 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to update the `metadata` property on an invoice. If you pass null for + * the metadata value, it will clear any existing metadata for that invoice. + * + * `metadata` can be modified regardless of invoice state. + */ class InvoiceUpdateParams constructor( private val invoiceId: String, @@ -33,12 +41,19 @@ constructor( */ fun metadata(): Optional = body.metadata() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): InvoiceUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -56,7 +71,9 @@ constructor( class InvoiceUpdateBody @JsonCreator internal constructor( - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -66,12 +83,28 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoiceUpdateBody = apply { + if (!validated) { + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -81,7 +114,7 @@ constructor( class Builder { - private var metadata: Metadata? = null + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -95,7 +128,7 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -104,6 +137,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -184,6 +224,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -282,25 +348,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): InvoiceUpdateParams = InvoiceUpdateParams( checkNotNull(invoiceId) { "`invoiceId` is required but was not set" }, @@ -327,6 +374,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt index 3c471265..646277d2 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/InvoiceVoidInvoiceParams.kt @@ -10,6 +10,14 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows an invoice's status to be set the `void` status. This can only be done to + * invoices that are in the `issued` status. + * + * If the associated invoice has used the customer balance to change the amount due, the customer + * balance operation will be reverted. For example, if the invoice used $10 of customer balance, + * that amount will be added back to the customer balance upon voiding. + */ class InvoiceVoidInvoiceParams constructor( private val invoiceId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt index 48281b09..8a6b40a0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Item.kt @@ -47,15 +47,17 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("external_connections") @ExcludeMissing - fun _externalConnections() = externalConnections + fun _externalConnections(): JsonField> = externalConnections - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -82,17 +84,17 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var externalConnections: JsonField> = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var externalConnections: JsonField>? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(item: Item) = apply { id = item.id createdAt = item.createdAt - externalConnections = item.externalConnections + externalConnections = item.externalConnections.map { it.toMutableList() } name = item.name additionalProperties = item.additionalProperties.toMutableMap() } @@ -109,7 +111,20 @@ private constructor( externalConnections(JsonField.of(externalConnections)) fun externalConnections(externalConnections: JsonField>) = apply { - this.externalConnections = externalConnections + this.externalConnections = externalConnections.map { it.toMutableList() } + } + + fun addExternalConnection(externalConnection: ExternalConnection) = apply { + externalConnections = + (externalConnections ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(externalConnection) + } } fun name(name: String) = name(JsonField.of(name)) @@ -137,10 +152,13 @@ private constructor( fun build(): Item = Item( - id, - createdAt, - externalConnections.map { it.toImmutable() }, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(externalConnections) { + "`externalConnections` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -166,11 +184,11 @@ private constructor( @JsonProperty("external_connection_name") @ExcludeMissing - fun _externalConnectionName() = externalConnectionName + fun _externalConnectionName(): JsonField = externalConnectionName @JsonProperty("external_entity_id") @ExcludeMissing - fun _externalEntityId() = externalEntityId + fun _externalEntityId(): JsonField = externalEntityId @JsonAnyGetter @ExcludeMissing @@ -195,8 +213,8 @@ private constructor( class Builder { - private var externalConnectionName: JsonField = JsonMissing.of() - private var externalEntityId: JsonField = JsonMissing.of() + private var externalConnectionName: JsonField? = null + private var externalEntityId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -242,8 +260,12 @@ private constructor( fun build(): ExternalConnection = ExternalConnection( - externalConnectionName, - externalEntityId, + checkNotNull(externalConnectionName) { + "`externalConnectionName` is required but was not set" + }, + checkNotNull(externalEntityId) { + "`externalEntityId` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt index 5d6d559d..5fe6f360 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -15,6 +17,7 @@ import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import java.util.Objects +/** This endpoint is used to create an [Item](../guides/concepts#item). */ class ItemCreateParams constructor( private val body: ItemCreateBody, @@ -25,12 +28,15 @@ constructor( /** The name of the item. */ fun name(): String = body.name() + /** The name of the item. */ + fun _name(): JsonField = body._name() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): ItemCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -41,18 +47,32 @@ constructor( class ItemCreateBody @JsonCreator internal constructor( - @JsonProperty("name") private val name: String, + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The name of the item. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** The name of the item. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ItemCreateBody = apply { + if (!validated) { + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -62,7 +82,7 @@ constructor( class Builder { - private var name: String? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -72,7 +92,10 @@ constructor( } /** The name of the item. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the item. */ + fun name(name: JsonField) = apply { this.name = name } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -142,6 +165,28 @@ constructor( /** The name of the item. */ fun name(name: String) = apply { body.name(name) } + /** The name of the item. */ + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -240,25 +285,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): ItemCreateParams = ItemCreateParams( body.build(), diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt index 0770e879..98d1024d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemFetchParams.kt @@ -7,6 +7,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** This endpoint returns an item identified by its item_id. */ class ItemFetchParams constructor( private val itemId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt index a465ffc9..f6b58d0a 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemListParams.kt @@ -8,6 +8,7 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** This endpoint returns a list of all Items, ordered in descending order by creation time. */ class ItemListParams constructor( private val cursor: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt index d6ed6032..08d5a616 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/ItemUpdateParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -19,6 +20,7 @@ import com.withorb.api.errors.OrbInvalidDataException import java.util.Objects import java.util.Optional +/** This endpoint can be used to update properties on the Item. */ class ItemUpdateParams constructor( private val itemId: String, @@ -33,12 +35,16 @@ constructor( fun name(): Optional = body.name() - fun _additionalHeaders(): Headers = additionalHeaders + fun _externalConnections(): JsonField> = body._externalConnections() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _name(): JsonField = body._name() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): ItemUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -62,22 +68,40 @@ constructor( @JsonCreator internal constructor( @JsonProperty("external_connections") - private val externalConnections: List?, - @JsonProperty("name") private val name: String?, + @ExcludeMissing + private val externalConnections: JsonField> = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("external_connections") fun externalConnections(): Optional> = - Optional.ofNullable(externalConnections) + Optional.ofNullable(externalConnections.getNullable("external_connections")) + + fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("name") fun name(): Optional = Optional.ofNullable(name) + @JsonProperty("external_connections") + @ExcludeMissing + fun _externalConnections(): JsonField> = externalConnections + + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ItemUpdateBody = apply { + if (!validated) { + externalConnections().map { it.forEach { it.validate() } } + name() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -87,33 +111,47 @@ constructor( class Builder { - private var externalConnections: MutableList? = null - private var name: String? = null + private var externalConnections: JsonField>? = null + private var name: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(itemUpdateBody: ItemUpdateBody) = apply { - externalConnections = itemUpdateBody.externalConnections?.toMutableList() + externalConnections = itemUpdateBody.externalConnections.map { it.toMutableList() } name = itemUpdateBody.name additionalProperties = itemUpdateBody.additionalProperties.toMutableMap() } - fun externalConnections(externalConnections: List?) = apply { - this.externalConnections = externalConnections?.toMutableList() - } + fun externalConnections(externalConnections: List?) = + externalConnections(JsonField.ofNullable(externalConnections)) fun externalConnections(externalConnections: Optional>) = externalConnections(externalConnections.orElse(null)) + fun externalConnections(externalConnections: JsonField>) = + apply { + this.externalConnections = externalConnections.map { it.toMutableList() } + } + fun addExternalConnection(externalConnection: ExternalConnection) = apply { externalConnections = - (externalConnections ?: mutableListOf()).apply { add(externalConnection) } + (externalConnections ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(externalConnection) + } } - fun name(name: String?) = apply { this.name = name } + fun name(name: String?) = name(JsonField.ofNullable(name)) fun name(name: Optional) = name(name.orElse(null)) + fun name(name: JsonField) = apply { this.name = name } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -135,7 +173,7 @@ constructor( fun build(): ItemUpdateBody = ItemUpdateBody( - externalConnections?.toImmutable(), + (externalConnections ?: JsonMissing.of()).map { it.toImmutable() }, name, additionalProperties.toImmutable(), ) @@ -191,6 +229,10 @@ constructor( fun externalConnections(externalConnections: Optional>) = externalConnections(externalConnections.orElse(null)) + fun externalConnections(externalConnections: JsonField>) = apply { + body.externalConnections(externalConnections) + } + fun addExternalConnection(externalConnection: ExternalConnection) = apply { body.addExternalConnection(externalConnection) } @@ -199,6 +241,27 @@ constructor( fun name(name: Optional) = name(name.orElse(null)) + fun name(name: JsonField) = apply { body.name(name) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -297,25 +360,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): ItemUpdateParams = ItemUpdateParams( checkNotNull(itemId) { "`itemId` is required but was not set" }, @@ -330,21 +374,42 @@ constructor( @JsonCreator private constructor( @JsonProperty("external_connection_name") - private val externalConnectionName: ExternalConnectionName, - @JsonProperty("external_entity_id") private val externalEntityId: String, + @ExcludeMissing + private val externalConnectionName: JsonField = JsonMissing.of(), + @JsonProperty("external_entity_id") + @ExcludeMissing + private val externalEntityId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun externalConnectionName(): ExternalConnectionName = + externalConnectionName.getRequired("external_connection_name") + + fun externalEntityId(): String = externalEntityId.getRequired("external_entity_id") + @JsonProperty("external_connection_name") - fun externalConnectionName(): ExternalConnectionName = externalConnectionName + @ExcludeMissing + fun _externalConnectionName(): JsonField = externalConnectionName - @JsonProperty("external_entity_id") fun externalEntityId(): String = externalEntityId + @JsonProperty("external_entity_id") + @ExcludeMissing + fun _externalEntityId(): JsonField = externalEntityId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ExternalConnection = apply { + if (!validated) { + externalConnectionName() + externalEntityId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -354,8 +419,8 @@ constructor( class Builder { - private var externalConnectionName: ExternalConnectionName? = null - private var externalEntityId: String? = null + private var externalConnectionName: JsonField? = null + private var externalEntityId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -365,11 +430,18 @@ constructor( additionalProperties = externalConnection.additionalProperties.toMutableMap() } - fun externalConnectionName(externalConnectionName: ExternalConnectionName) = apply { - this.externalConnectionName = externalConnectionName - } + fun externalConnectionName(externalConnectionName: ExternalConnectionName) = + externalConnectionName(JsonField.of(externalConnectionName)) + + fun externalConnectionName(externalConnectionName: JsonField) = + apply { + this.externalConnectionName = externalConnectionName + } + + fun externalEntityId(externalEntityId: String) = + externalEntityId(JsonField.of(externalEntityId)) - fun externalEntityId(externalEntityId: String) = apply { + fun externalEntityId(externalEntityId: JsonField) = apply { this.externalEntityId = externalEntityId } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt index 967cbe45..37864119 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricCreateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint is used to create a [metric](../guides/concepts##metric) using a SQL string. See + * [SQL support](../guides/extensibility/advanced-metrics#sql-support) for a description of + * constructing SQL queries with examples. + */ class MetricCreateParams constructor( private val body: MetricCreateBody, @@ -42,12 +49,31 @@ constructor( */ fun metadata(): Optional = body.metadata() - fun _additionalHeaders(): Headers = additionalHeaders + /** A description of the metric. */ + fun _description(): JsonField = body._description() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The id of the item */ + fun _itemId(): JsonField = body._itemId() + + /** The name of the metric. */ + fun _name(): JsonField = body._name() + + /** A sql string defining the metric. */ + fun _sql(): JsonField = body._sql() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): MetricCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -58,39 +84,81 @@ constructor( class MetricCreateBody @JsonCreator internal constructor( - @JsonProperty("description") private val description: String?, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("name") private val name: String, - @JsonProperty("sql") private val sql: String, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("description") + @ExcludeMissing + private val description: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("sql") @ExcludeMissing private val sql: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** A description of the metric. */ + fun description(): Optional = + Optional.ofNullable(description.getNullable("description")) + + /** The id of the item */ + fun itemId(): String = itemId.getRequired("item_id") + + /** The name of the metric. */ + fun name(): String = name.getRequired("name") + + /** A sql string defining the metric. */ + fun sql(): String = sql.getRequired("sql") + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** A description of the metric. */ @JsonProperty("description") - fun description(): Optional = Optional.ofNullable(description) + @ExcludeMissing + fun _description(): JsonField = description /** The id of the item */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** The name of the metric. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** A sql string defining the metric. */ - @JsonProperty("sql") fun sql(): String = sql + @JsonProperty("sql") @ExcludeMissing fun _sql(): JsonField = sql /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MetricCreateBody = apply { + if (!validated) { + description() + itemId() + name() + sql() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -100,11 +168,11 @@ constructor( class Builder { - private var description: String? = null - private var itemId: String? = null - private var name: String? = null - private var sql: String? = null - private var metadata: Metadata? = null + private var description: JsonField? = null + private var itemId: JsonField? = null + private var name: JsonField? = null + private var sql: JsonField? = null + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -118,26 +186,40 @@ constructor( } /** A description of the metric. */ - fun description(description: String?) = apply { this.description = description } + fun description(description: String?) = description(JsonField.ofNullable(description)) /** A description of the metric. */ fun description(description: Optional) = description(description.orElse(null)) + /** A description of the metric. */ + fun description(description: JsonField) = apply { + this.description = description + } + + /** The id of the item */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + /** The id of the item */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } /** The name of the metric. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the metric. */ + fun name(name: JsonField) = apply { this.name = name } + + /** A sql string defining the metric. */ + fun sql(sql: String) = sql(JsonField.of(sql)) /** A sql string defining the metric. */ - fun sql(sql: String) = apply { this.sql = sql } + fun sql(sql: JsonField) = apply { this.sql = sql } /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -146,6 +228,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -167,7 +256,7 @@ constructor( fun build(): MetricCreateBody = MetricCreateBody( - description, + checkNotNull(description) { "`description` is required but was not set" }, checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, checkNotNull(sql) { "`sql` is required but was not set" }, @@ -221,15 +310,27 @@ constructor( /** A description of the metric. */ fun description(description: Optional) = description(description.orElse(null)) + /** A description of the metric. */ + fun description(description: JsonField) = apply { body.description(description) } + /** The id of the item */ fun itemId(itemId: String) = apply { body.itemId(itemId) } + /** The id of the item */ + fun itemId(itemId: JsonField) = apply { body.itemId(itemId) } + /** The name of the metric. */ fun name(name: String) = apply { body.name(name) } + /** The name of the metric. */ + fun name(name: JsonField) = apply { body.name(name) } + /** A sql string defining the metric. */ fun sql(sql: String) = apply { body.sql(sql) } + /** A sql string defining the metric. */ + fun sql(sql: JsonField) = apply { body.sql(sql) } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -244,6 +345,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -342,25 +469,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): MetricCreateParams = MetricCreateParams( body.build(), @@ -386,6 +494,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt index 33bdf9c9..d1ddb626 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricFetchParams.kt @@ -7,6 +7,10 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to list [metrics](../guides/concepts##metric). It returns information about + * the metrics including its name, description, and item. + */ class MetricFetchParams constructor( private val metricId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt index d2e12d65..b052c588 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricListParams.kt @@ -10,6 +10,10 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint is used to fetch [metric](../guides/concepts#metric) details given a metric + * identifier. It returns information about the metrics including its name, description, and item. + */ class MetricListParams constructor( private val createdAtGt: OffsetDateTime?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt index 2cd90ec6..b9b04850 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/MetricUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,10 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to update the `metadata` property on a metric. If you pass `null` for + * the metadata value, it will clear any existing metadata for that invoice. + */ class MetricUpdateParams constructor( private val metricId: String, @@ -33,12 +39,19 @@ constructor( */ fun metadata(): Optional = body.metadata() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): MetricUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -56,7 +69,9 @@ constructor( class MetricUpdateBody @JsonCreator internal constructor( - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -66,12 +81,28 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MetricUpdateBody = apply { + if (!validated) { + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -81,7 +112,7 @@ constructor( class Builder { - private var metadata: Metadata? = null + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -95,7 +126,7 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -104,6 +135,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -184,6 +222,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -282,25 +346,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): MetricUpdateParams = MetricUpdateParams( checkNotNull(metricId) { "`metricId` is required but was not set" }, @@ -327,6 +372,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt index 4464fb6d..1d1de4ab 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PaginationMetadata.kt @@ -33,9 +33,9 @@ private constructor( fun nextCursor(): Optional = Optional.ofNullable(nextCursor.getNullable("next_cursor")) - @JsonProperty("has_more") @ExcludeMissing fun _hasMore() = hasMore + @JsonProperty("has_more") @ExcludeMissing fun _hasMore(): JsonField = hasMore - @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor() = nextCursor + @JsonProperty("next_cursor") @ExcludeMissing fun _nextCursor(): JsonField = nextCursor @JsonAnyGetter @ExcludeMissing @@ -60,8 +60,8 @@ private constructor( class Builder { - private var hasMore: JsonField = JsonMissing.of() - private var nextCursor: JsonField = JsonMissing.of() + private var hasMore: JsonField? = null + private var nextCursor: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -75,7 +75,9 @@ private constructor( fun hasMore(hasMore: JsonField) = apply { this.hasMore = hasMore } - fun nextCursor(nextCursor: String) = nextCursor(JsonField.of(nextCursor)) + fun nextCursor(nextCursor: String?) = nextCursor(JsonField.ofNullable(nextCursor)) + + fun nextCursor(nextCursor: Optional) = nextCursor(nextCursor.orElse(null)) fun nextCursor(nextCursor: JsonField) = apply { this.nextCursor = nextCursor } @@ -100,8 +102,8 @@ private constructor( fun build(): PaginationMetadata = PaginationMetadata( - hasMore, - nextCursor, + checkNotNull(hasMore) { "`hasMore` is required but was not set" }, + checkNotNull(nextCursor) { "`nextCursor` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt index 42970b62..c5448677 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PercentageDiscount.kt @@ -56,16 +56,18 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** Only available if discount_type is `percentage`. This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -92,15 +94,15 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null private var reason: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscount: PercentageDiscount) = apply { - appliesToPriceIds = percentageDiscount.appliesToPriceIds + appliesToPriceIds = percentageDiscount.appliesToPriceIds.map { it.toMutableList() } discountType = percentageDiscount.discountType this.percentageDiscount = percentageDiscount.percentageDiscount reason = percentageDiscount.reason @@ -119,7 +121,24 @@ private constructor( * be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -137,7 +156,9 @@ private constructor( this.percentageDiscount = percentageDiscount } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } @@ -162,9 +183,14 @@ private constructor( fun build(): PercentageDiscount = PercentageDiscount( - appliesToPriceIds.map { it.toImmutable() }, - discountType, - percentageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, reason, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt index d64e13ea..a5a86d04 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Plan.kt @@ -199,26 +199,30 @@ private constructor( fun version(): Long = version.getRequired("version") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * Adjustments for this plan. If the plan has phases, this includes adjustments across all * phases of the plan. */ - @JsonProperty("adjustments") @ExcludeMissing fun _adjustments() = adjustments + @JsonProperty("adjustments") + @ExcludeMissing + fun _adjustments(): JsonField> = adjustments - @JsonProperty("base_plan") @ExcludeMissing fun _basePlan() = basePlan + @JsonProperty("base_plan") @ExcludeMissing fun _basePlan(): JsonField = basePlan /** * The parent plan id if the given plan was created by overriding one or more of the parent's * prices */ - @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId() = basePlanId + @JsonProperty("base_plan_id") @ExcludeMissing fun _basePlanId(): JsonField = basePlanId - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** An ISO 4217 currency string or custom pricing unit (`credits`) for this plan's prices. */ - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * The default memo text on the invoices corresponding to subscriptions on this plan. Note that @@ -226,40 +230,48 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") @ExcludeMissing fun _description(): JsonField = description - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** * An optional user-defined ID for this plan resource, used throughout the system as an alias * for this Plan. Use this field to identify a plan by an existing identifier in your system. */ - @JsonProperty("external_plan_id") @ExcludeMissing fun _externalPlanId() = externalPlanId + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId /** * An ISO 4217 currency string for which this plan is billed in. Matches `currency` unless * `currency` is a custom pricing unit. */ - @JsonProperty("invoicing_currency") @ExcludeMissing fun _invoicingCurrency() = invoicingCurrency + @JsonProperty("invoicing_currency") + @ExcludeMissing + fun _invoicingCurrency(): JsonField = invoicingCurrency - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Determines the difference between the invoice issue date and the due date. A value of "0" @@ -267,23 +279,27 @@ private constructor( * customer has a month to pay the invoice before its overdue. Note that individual * subscriptions or invoices may set a different net terms configuration. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms - @JsonProperty("plan_phases") @ExcludeMissing fun _planPhases() = planPhases + @JsonProperty("plan_phases") + @ExcludeMissing + fun _planPhases(): JsonField> = planPhases /** * Prices for this plan. If the plan has phases, this includes prices across all phases of the * plan. */ - @JsonProperty("prices") @ExcludeMissing fun _prices() = prices + @JsonProperty("prices") @ExcludeMissing fun _prices(): JsonField> = prices - @JsonProperty("product") @ExcludeMissing fun _product() = product + @JsonProperty("product") @ExcludeMissing fun _product(): JsonField = product - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_config") @ExcludeMissing fun _trialConfig() = trialConfig + @JsonProperty("trial_config") + @ExcludeMissing + fun _trialConfig(): JsonField = trialConfig - @JsonProperty("version") @ExcludeMissing fun _version() = version + @JsonProperty("version") @ExcludeMissing fun _version(): JsonField = version @JsonAnyGetter @ExcludeMissing @@ -330,36 +346,36 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustments: JsonField> = JsonMissing.of() - private var basePlan: JsonField = JsonMissing.of() - private var basePlanId: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPlanId: JsonField = JsonMissing.of() - private var invoicingCurrency: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var planPhases: JsonField> = JsonMissing.of() - private var prices: JsonField> = JsonMissing.of() - private var product: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialConfig: JsonField = JsonMissing.of() - private var version: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustments: JsonField>? = null + private var basePlan: JsonField? = null + private var basePlanId: JsonField? = null + private var createdAt: JsonField? = null + private var currency: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var description: JsonField? = null + private var discount: JsonField? = null + private var externalPlanId: JsonField? = null + private var invoicingCurrency: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var netTerms: JsonField? = null + private var planPhases: JsonField>? = null + private var prices: JsonField>? = null + private var product: JsonField? = null + private var status: JsonField? = null + private var trialConfig: JsonField? = null + private var version: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(plan: Plan) = apply { id = plan.id - adjustments = plan.adjustments + adjustments = plan.adjustments.map { it.toMutableList() } basePlan = plan.basePlan basePlanId = plan.basePlanId createdAt = plan.createdAt @@ -376,8 +392,8 @@ private constructor( minimumAmount = plan.minimumAmount name = plan.name netTerms = plan.netTerms - planPhases = plan.planPhases - prices = plan.prices + planPhases = plan.planPhases.map { it.toMutableList() } + prices = plan.prices.map { it.toMutableList() } product = plan.product status = plan.status trialConfig = plan.trialConfig @@ -400,10 +416,29 @@ private constructor( * phases of the plan. */ fun adjustments(adjustments: JsonField>) = apply { - this.adjustments = adjustments + this.adjustments = adjustments.map { it.toMutableList() } } - fun basePlan(basePlan: BasePlan) = basePlan(JsonField.of(basePlan)) + /** + * Adjustments for this plan. If the plan has phases, this includes adjustments across all + * phases of the plan. + */ + fun addAdjustment(adjustment: Adjustment) = apply { + adjustments = + (adjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustment) + } + } + + fun basePlan(basePlan: BasePlan?) = basePlan(JsonField.ofNullable(basePlan)) + + fun basePlan(basePlan: Optional) = basePlan(basePlan.orElse(null)) fun basePlan(basePlan: JsonField) = apply { this.basePlan = basePlan } @@ -411,7 +446,13 @@ private constructor( * The parent plan id if the given plan was created by overriding one or more of the * parent's prices */ - fun basePlanId(basePlanId: String) = basePlanId(JsonField.of(basePlanId)) + fun basePlanId(basePlanId: String?) = basePlanId(JsonField.ofNullable(basePlanId)) + + /** + * The parent plan id if the given plan was created by overriding one or more of the + * parent's prices + */ + fun basePlanId(basePlanId: Optional) = basePlanId(basePlanId.orElse(null)) /** * The parent plan id if the given plan was created by overriding one or more of the @@ -437,8 +478,15 @@ private constructor( * The default memo text on the invoices corresponding to subscriptions on this plan. Note * that each subscription may configure its own memo. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * The default memo text on the invoices corresponding to subscriptions on this plan. Note + * that each subscription may configure its own memo. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * The default memo text on the invoices corresponding to subscriptions on this plan. Note @@ -452,16 +500,39 @@ private constructor( fun description(description: JsonField) = apply { this.description = description } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your * system. */ - fun externalPlanId(externalPlanId: String) = externalPlanId(JsonField.of(externalPlanId)) + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -487,11 +558,17 @@ private constructor( this.invoicingCurrency = invoicingCurrency } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -511,11 +588,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -531,7 +614,24 @@ private constructor( * customer has a month to pay the invoice before its overdue. Note that individual * subscriptions or invoices may set a different net terms configuration. */ - fun netTerms(netTerms: Long) = netTerms(JsonField.of(netTerms)) + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + fun netTerms(netTerms: Long) = netTerms(netTerms as Long?) + + /** + * Determines the difference between the invoice issue date and the due date. A value of "0" + * here signifies that invoices are due on issue, whereas a value of "30" means that the + * customer has a month to pay the invoice before its overdue. Note that individual + * subscriptions or invoices may set a different net terms configuration. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) /** * Determines the difference between the invoice issue date and the due date. A value of "0" @@ -541,10 +641,25 @@ private constructor( */ fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } - fun planPhases(planPhases: List) = planPhases(JsonField.of(planPhases)) + fun planPhases(planPhases: List?) = planPhases(JsonField.ofNullable(planPhases)) + + fun planPhases(planPhases: Optional>) = planPhases(planPhases.orElse(null)) fun planPhases(planPhases: JsonField>) = apply { - this.planPhases = planPhases + this.planPhases = planPhases.map { it.toMutableList() } + } + + fun addPlanPhase(planPhase: PlanPhase) = apply { + planPhases = + (planPhases ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(planPhase) + } } /** @@ -557,7 +672,26 @@ private constructor( * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - fun prices(prices: JsonField>) = apply { this.prices = prices } + fun prices(prices: JsonField>) = apply { + this.prices = prices.map { it.toMutableList() } + } + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun addPrice(price: Price) = apply { + prices = + (prices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(price) + } + } fun product(product: Product) = product(JsonField.of(product)) @@ -598,30 +732,37 @@ private constructor( fun build(): Plan = Plan( - id, - adjustments.map { it.toImmutable() }, - basePlan, - basePlanId, - createdAt, - currency, - defaultInvoiceMemo, - description, - discount, - externalPlanId, - invoicingCurrency, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - name, - netTerms, - planPhases.map { it.toImmutable() }, - prices.map { it.toImmutable() }, - product, - status, - trialConfig, - version, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustments) { "`adjustments` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(basePlan) { "`basePlan` is required but was not set" }, + checkNotNull(basePlanId) { "`basePlanId` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPlanId) { "`externalPlanId` is required but was not set" }, + checkNotNull(invoicingCurrency) { + "`invoicingCurrency` is required but was not set" + }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(planPhases) { "`planPhases` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(prices) { "`prices` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(product) { "`product` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialConfig) { "`trialConfig` is required but was not set" }, + checkNotNull(version) { "`version` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -913,32 +1054,40 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment_type") @ExcludeMissing fun _adjustmentType() = adjustmentType + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given * billing period. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that * apply to only one price. */ - @JsonProperty("is_invoice_level") @ExcludeMissing fun _isInvoiceLevel() = isInvoiceLevel + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -968,13 +1117,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -982,7 +1131,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1022,7 +1172,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1041,8 +1205,16 @@ private constructor( } /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1050,7 +1222,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1079,13 +1254,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1215,20 +1401,24 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment_type") @ExcludeMissing fun _adjustmentType() = adjustmentType + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that * apply to only one price. */ - @JsonProperty("is_invoice_level") @ExcludeMissing fun _isInvoiceLevel() = isInvoiceLevel + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price intervals @@ -1236,13 +1426,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1272,13 +1464,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1286,7 +1478,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1312,7 +1507,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1346,8 +1555,16 @@ private constructor( } /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1355,7 +1572,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1384,13 +1604,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1520,32 +1751,40 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment_type") @ExcludeMissing fun _adjustmentType() = adjustmentType + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that * apply to only one price. */ - @JsonProperty("is_invoice_level") @ExcludeMissing fun _isInvoiceLevel() = isInvoiceLevel + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies to * in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1575,20 +1814,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1614,7 +1854,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1633,8 +1887,16 @@ private constructor( } /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1642,7 +1904,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1686,13 +1951,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1828,35 +2104,43 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment_type") @ExcludeMissing fun _adjustmentType() = adjustmentType + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that * apply to only one price. */ - @JsonProperty("is_invoice_level") @ExcludeMissing fun _isInvoiceLevel() = isInvoiceLevel + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this adjustment * applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1887,21 +2171,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -1927,7 +2212,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1967,8 +2266,16 @@ private constructor( } /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1976,7 +2283,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2005,14 +2315,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2142,32 +2463,40 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment_type") @ExcludeMissing fun _adjustmentType() = adjustmentType + @JsonProperty("adjustment_type") + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that * apply to only one price. */ - @JsonProperty("is_invoice_level") @ExcludeMissing fun _isInvoiceLevel() = isInvoiceLevel + @JsonProperty("is_invoice_level") + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this adjustment * applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2197,20 +2526,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2235,7 +2565,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2269,8 +2613,16 @@ private constructor( } /** The plan phase in which this adjustment is active. */ - fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2278,7 +2630,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2307,13 +2662,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2415,16 +2781,18 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your * system. */ - @JsonProperty("external_plan_id") @ExcludeMissing fun _externalPlanId() = externalPlanId + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2450,9 +2818,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalPlanId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2463,7 +2831,9 @@ private constructor( additionalProperties = basePlan.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun id(id: String?) = id(JsonField.ofNullable(id)) + + fun id(id: Optional) = id(id.orElse(null)) fun id(id: JsonField) = apply { this.id = id } @@ -2472,8 +2842,16 @@ private constructor( * alias for this Plan. Use this field to identify a plan by an existing identifier in * your system. */ - fun externalPlanId(externalPlanId: String) = - externalPlanId(JsonField.of(externalPlanId)) + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -2484,7 +2862,9 @@ private constructor( this.externalPlanId = externalPlanId } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) fun name(name: JsonField) = apply { this.name = name } @@ -2509,9 +2889,9 @@ private constructor( fun build(): BasePlan = BasePlan( - id, - externalPlanId, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalPlanId) { "`externalPlanId` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2564,10 +2944,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -2592,13 +2974,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -2615,7 +2997,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase maximums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -2647,8 +3046,11 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2781,10 +3183,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -2809,13 +3213,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -2832,7 +3236,24 @@ private constructor( * this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase minimums, + * this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -2864,8 +3285,11 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2958,32 +3382,40 @@ private constructor( /** Determines the ordering of the phase in a plan's lifecycle. 1 = first phase. */ fun order(): Long = order.getRequired("order") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("description") @ExcludeMissing fun _description() = description + @JsonProperty("description") + @ExcludeMissing + fun _description(): JsonField = description - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount /** * How many terms of length `duration_unit` this phase is active for. If null, this phase is * evergreen and active indefinitely */ - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** Determines the ordering of the phase in a plan's lifecycle. 1 = first phase. */ - @JsonProperty("order") @ExcludeMissing fun _order() = order + @JsonProperty("order") @ExcludeMissing fun _order(): JsonField = order @JsonAnyGetter @ExcludeMissing @@ -3017,17 +3449,17 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var description: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var order: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var description: JsonField? = null + private var discount: JsonField? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var name: JsonField? = null + private var order: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3050,21 +3482,50 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun description(description: String) = description(JsonField.of(description)) + fun description(description: String?) = description(JsonField.ofNullable(description)) + + fun description(description: Optional) = description(description.orElse(null)) fun description(description: JsonField) = apply { this.description = description } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this + * phase is evergreen and active indefinitely + */ + fun duration(duration: Long?) = duration(JsonField.ofNullable(duration)) + + /** + * How many terms of length `duration_unit` this phase is active for. If null, this + * phase is evergreen and active indefinitely + */ + fun duration(duration: Long) = duration(duration as Long?) + /** * How many terms of length `duration_unit` this phase is active for. If null, this * phase is evergreen and active indefinitely */ - fun duration(duration: Long) = duration(JsonField.of(duration)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun duration(duration: Optional) = duration(duration.orElse(null) as Long?) /** * How many terms of length `duration_unit` this phase is active for. If null, this @@ -3072,27 +3533,43 @@ private constructor( */ fun duration(duration: JsonField) = apply { this.duration = duration } - fun durationUnit(durationUnit: DurationUnit) = durationUnit(JsonField.of(durationUnit)) + fun durationUnit(durationUnit: DurationUnit?) = + durationUnit(JsonField.ofNullable(durationUnit)) + + fun durationUnit(durationUnit: Optional) = + durationUnit(durationUnit.orElse(null)) fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -3129,17 +3606,17 @@ private constructor( fun build(): PlanPhase = PlanPhase( - id, - description, - discount, - duration, - durationUnit, - maximum, - maximumAmount, - minimum, - minimumAmount, - name, - order, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(description) { "`description` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(order) { "`order` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3249,10 +3726,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -3277,13 +3756,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -3300,7 +3779,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -3336,8 +3832,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3390,10 +3891,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -3418,13 +3921,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -3441,7 +3944,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -3477,8 +3997,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3540,11 +4065,13 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -3570,9 +4097,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var createdAt: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3618,9 +4145,9 @@ private constructor( fun build(): Product = Product( - id, - createdAt, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3725,9 +4252,13 @@ private constructor( fun trialPeriodUnit(): TrialPeriodUnit = trialPeriodUnit.getRequired("trial_period_unit") - @JsonProperty("trial_period") @ExcludeMissing fun _trialPeriod() = trialPeriod + @JsonProperty("trial_period") + @ExcludeMissing + fun _trialPeriod(): JsonField = trialPeriod - @JsonProperty("trial_period_unit") @ExcludeMissing fun _trialPeriodUnit() = trialPeriodUnit + @JsonProperty("trial_period_unit") + @ExcludeMissing + fun _trialPeriodUnit(): JsonField = trialPeriodUnit @JsonAnyGetter @ExcludeMissing @@ -3752,8 +4283,8 @@ private constructor( class Builder { - private var trialPeriod: JsonField = JsonMissing.of() - private var trialPeriodUnit: JsonField = JsonMissing.of() + private var trialPeriod: JsonField? = null + private var trialPeriodUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3763,7 +4294,13 @@ private constructor( additionalProperties = trialConfig.additionalProperties.toMutableMap() } - fun trialPeriod(trialPeriod: Long) = trialPeriod(JsonField.of(trialPeriod)) + fun trialPeriod(trialPeriod: Long?) = trialPeriod(JsonField.ofNullable(trialPeriod)) + + fun trialPeriod(trialPeriod: Long) = trialPeriod(trialPeriod as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun trialPeriod(trialPeriod: Optional) = + trialPeriod(trialPeriod.orElse(null) as Long?) fun trialPeriod(trialPeriod: JsonField) = apply { this.trialPeriod = trialPeriod } @@ -3795,8 +4332,10 @@ private constructor( fun build(): TrialConfig = TrialConfig( - trialPeriod, - trialPeriodUnit, + checkNotNull(trialPeriod) { "`trialPeriod` is required but was not set" }, + checkNotNull(trialPeriodUnit) { + "`trialPeriodUnit` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt index ff338b26..9b2d17bf 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanCreateParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,7 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** This endpoint allows creation of plans including their prices. */ class PlanCreateParams constructor( private val body: PlanCreateBody, @@ -72,12 +74,47 @@ constructor( */ fun status(): Optional = body.status() - fun _additionalHeaders(): Headers = additionalHeaders + /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ + fun _currency(): JsonField = body._currency() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _name(): JsonField = body._name() + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of the + * plan. + */ + fun _prices(): JsonField> = body._prices() + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun _defaultInvoiceMemo(): JsonField = body._defaultInvoiceMemo() + + fun _externalPlanId(): JsonField = body._externalPlanId() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * The net terms determines the difference between the invoice date and the issue date for the + * invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun _netTerms(): JsonField = body._netTerms() + + /** + * The status of the plan to create (either active or draft). If not specified, this defaults to + * active. + */ + fun _status(): JsonField = body._status() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): PlanCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -88,59 +125,130 @@ constructor( class PlanCreateBody @JsonCreator internal constructor( - @JsonProperty("currency") private val currency: String, - @JsonProperty("name") private val name: String, - @JsonProperty("prices") private val prices: List, - @JsonProperty("default_invoice_memo") private val defaultInvoiceMemo: String?, - @JsonProperty("external_plan_id") private val externalPlanId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("net_terms") private val netTerms: Long?, - @JsonProperty("status") private val status: Status?, + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("prices") + @ExcludeMissing + private val prices: JsonField> = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("status") + @ExcludeMissing + private val status: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") + + fun name(): String = name.getRequired("name") + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun prices(): List = prices.getRequired("prices") + + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun netTerms(): Optional = Optional.ofNullable(netTerms.getNullable("net_terms")) + + /** + * The status of the plan to create (either active or draft). If not specified, this + * defaults to active. + */ + fun status(): Optional = Optional.ofNullable(status.getNullable("status")) + + /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ - @JsonProperty("prices") fun prices(): List = prices + @JsonProperty("prices") @ExcludeMissing fun _prices(): JsonField> = prices /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ @JsonProperty("default_invoice_memo") - fun defaultInvoiceMemo(): Optional = Optional.ofNullable(defaultInvoiceMemo) + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo @JsonProperty("external_plan_id") - fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. */ - @JsonProperty("net_terms") fun netTerms(): Optional = Optional.ofNullable(netTerms) + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The status of the plan to create (either active or draft). If not specified, this * defaults to active. */ - @JsonProperty("status") fun status(): Optional = Optional.ofNullable(status) + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PlanCreateBody = apply { + if (!validated) { + currency() + name() + prices() + defaultInvoiceMemo() + externalPlanId() + metadata().map { it.validate() } + netTerms() + status() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -150,21 +258,21 @@ constructor( class Builder { - private var currency: String? = null - private var name: String? = null - private var prices: MutableList? = null - private var defaultInvoiceMemo: String? = null - private var externalPlanId: String? = null - private var metadata: Metadata? = null - private var netTerms: Long? = null - private var status: Status? = null + private var currency: JsonField? = null + private var name: JsonField? = null + private var prices: JsonField>? = null + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var externalPlanId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var status: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(planCreateBody: PlanCreateBody) = apply { currency = planCreateBody.currency name = planCreateBody.name - prices = planCreateBody.prices.toMutableList() + prices = planCreateBody.prices.map { it.toMutableList() } defaultInvoiceMemo = planCreateBody.defaultInvoiceMemo externalPlanId = planCreateBody.externalPlanId metadata = planCreateBody.metadata @@ -174,46 +282,75 @@ constructor( } /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun name(name: String) = name(JsonField.of(name)) - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases + * of the plan. + */ + fun prices(prices: List) = prices(JsonField.of(prices)) /** * Prices for this plan. If the plan has phases, this includes prices across all phases * of the plan. */ - fun prices(prices: List) = apply { this.prices = prices.toMutableList() } + fun prices(prices: JsonField>) = apply { + this.prices = prices.map { it.toMutableList() } + } /** * Prices for this plan. If the plan has phases, this includes prices across all phases * of the plan. */ fun addPrice(price: Price) = apply { - prices = (prices ?: mutableListOf()).apply { add(price) } + prices = + (prices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(price) + } } /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - fun externalPlanId(externalPlanId: String?) = apply { - this.externalPlanId = externalPlanId + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo } + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -222,11 +359,18 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. */ - fun netTerms(netTerms: Long?) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) /** * The net terms determines the difference between the invoice date and the issue date @@ -241,17 +385,23 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + /** * The status of the plan to create (either active or draft). If not specified, this * defaults to active. */ - fun status(status: Status?) = apply { this.status = status } + fun status(status: Status) = status(JsonField.of(status)) /** * The status of the plan to create (either active or draft). If not specified, this * defaults to active. */ - fun status(status: Optional) = status(status.orElse(null)) + fun status(status: JsonField) = apply { this.status = status } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -276,7 +426,8 @@ constructor( PlanCreateBody( checkNotNull(currency) { "`currency` is required but was not set" }, checkNotNull(name) { "`name` is required but was not set" }, - checkNotNull(prices) { "`prices` is required but was not set" }.toImmutable(), + checkNotNull(prices) { "`prices` is required but was not set" } + .map { it.toImmutable() }, defaultInvoiceMemo, externalPlanId, metadata, @@ -328,14 +479,25 @@ constructor( /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ fun currency(currency: String) = apply { body.currency(currency) } + /** An ISO 4217 currency string for invoices generated by subscriptions on this plan. */ + fun currency(currency: JsonField) = apply { body.currency(currency) } + fun name(name: String) = apply { body.name(name) } + fun name(name: JsonField) = apply { body.name(name) } + /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. */ fun prices(prices: List) = apply { body.prices(prices) } + /** + * Prices for this plan. If the plan has phases, this includes prices across all phases of + * the plan. + */ + fun prices(prices: JsonField>) = apply { body.prices(prices) } + /** * Prices for this plan. If the plan has phases, this includes prices across all phases of * the plan. @@ -351,11 +513,20 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + /** Free-form text which is available on the invoice PDF and the Orb invoice portal. */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + body.defaultInvoiceMemo(defaultInvoiceMemo) + } + fun externalPlanId(externalPlanId: String?) = apply { body.externalPlanId(externalPlanId) } fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + fun externalPlanId(externalPlanId: JsonField) = apply { + body.externalPlanId(externalPlanId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -370,6 +541,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. @@ -389,17 +567,42 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. + */ + fun netTerms(netTerms: JsonField) = apply { body.netTerms(netTerms) } + /** * The status of the plan to create (either active or draft). If not specified, this * defaults to active. */ - fun status(status: Status?) = apply { body.status(status) } + fun status(status: Status) = apply { body.status(status) } /** * The status of the plan to create (either active or draft). If not specified, this * defaults to active. */ - fun status(status: Optional) = status(status.orElse(null)) + fun status(status: JsonField) = apply { body.status(status) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -499,25 +702,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): PlanCreateParams = PlanCreateParams( body.build(), @@ -557,6 +741,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newPlanUnitPrice(): Optional = Optional.ofNullable(newPlanUnitPrice) fun newPlanPackagePrice(): Optional = @@ -780,6 +966,58 @@ constructor( } } + fun validate(): Price = apply { + if (!validated) { + if ( + newPlanUnitPrice == null && + newPlanPackagePrice == null && + newPlanMatrixPrice == null && + newPlanTieredPrice == null && + newPlanTieredBpsPrice == null && + newPlanBpsPrice == null && + newPlanBulkBpsPrice == null && + newPlanBulkPrice == null && + newPlanThresholdTotalAmountPrice == null && + newPlanTieredPackagePrice == null && + newPlanTieredWithMinimumPrice == null && + newPlanUnitWithPercentPrice == null && + newPlanPackageWithAllocationPrice == null && + newPlanTierWithProrationPrice == null && + newPlanUnitWithProrationPrice == null && + newPlanGroupedAllocationPrice == null && + newPlanGroupedWithProratedMinimumPrice == null && + newPlanGroupedWithMeteredMinimumPrice == null && + newPlanMatrixWithDisplayNamePrice == null && + newPlanBulkWithProrationPrice == null && + newPlanGroupedTieredPackagePrice == null + ) { + throw OrbInvalidDataException("Unknown Price: $_json") + } + newPlanUnitPrice?.validate() + newPlanPackagePrice?.validate() + newPlanMatrixPrice?.validate() + newPlanTieredPrice?.validate() + newPlanTieredBpsPrice?.validate() + newPlanBpsPrice?.validate() + newPlanBulkBpsPrice?.validate() + newPlanBulkPrice?.validate() + newPlanThresholdTotalAmountPrice?.validate() + newPlanTieredPackagePrice?.validate() + newPlanTieredWithMinimumPrice?.validate() + newPlanUnitWithPercentPrice?.validate() + newPlanPackageWithAllocationPrice?.validate() + newPlanTierWithProrationPrice?.validate() + newPlanUnitWithProrationPrice?.validate() + newPlanGroupedAllocationPrice?.validate() + newPlanGroupedWithProratedMinimumPrice?.validate() + newPlanGroupedWithMeteredMinimumPrice?.validate() + newPlanMatrixWithDisplayNamePrice?.validate() + newPlanBulkWithProrationPrice?.validate() + newPlanGroupedTieredPackagePrice?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1017,92 +1255,130 @@ constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanUnitPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Price(newPlanUnitPrice = it, _json = json) + } } "package" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanPackagePrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanPackagePrice = it, _json = json) + } } "matrix" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanMatrixPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Price(newPlanMatrixPrice = it, _json = json) + } } "tiered" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanTieredPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Price(newPlanTieredPrice = it, _json = json) + } } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanTieredBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanTieredBpsPrice = it, _json = json) + } } "bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Price(newPlanBpsPrice = it, _json = json) + } } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanBulkBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanBulkBpsPrice = it, _json = json) + } } "bulk" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanBulkPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Price(newPlanBulkPrice = it, _json = json) + } } "threshold_total_amount" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newPlanThresholdTotalAmountPrice = it, _json = json) } } "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanTieredPackagePrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanTieredPackagePrice = it, _json = json) + } } "tiered_with_minimum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanTieredWithMinimumPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanTieredWithMinimumPrice = it, _json = json) + } } "unit_with_percent" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanUnitWithPercentPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanUnitWithPercentPrice = it, _json = json) + } } "package_with_allocation" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newPlanPackageWithAllocationPrice = it, _json = json) } } "tiered_with_proration" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanTierWithProrationPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanTierWithProrationPrice = it, _json = json) + } } "unit_with_proration" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanUnitWithProrationPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanUnitWithProrationPrice = it, _json = json) + } } "grouped_allocation" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanGroupedAllocationPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanGroupedAllocationPrice = it, _json = json) + } } "grouped_with_prorated_minimum" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newPlanGroupedWithProratedMinimumPrice = it, @@ -1114,7 +1390,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newPlanGroupedWithMeteredMinimumPrice = it, @@ -1123,18 +1401,25 @@ constructor( } } "matrix_with_display_name" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newPlanMatrixWithDisplayNamePrice = it, _json = json) } } "bulk_with_proration" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newPlanBulkWithProrationPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newPlanBulkWithProrationPrice = it, _json = json) + } } "grouped_tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newPlanGroupedTieredPackagePrice = it, _json = json) } @@ -1202,92 +1487,208 @@ constructor( class NewPlanUnitPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1295,12 +1696,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanUnitPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1310,21 +1735,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1348,25 +1775,41 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -1375,13 +1818,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -1398,13 +1848,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -1414,10 +1872,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -1428,11 +1893,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -1440,22 +1910,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -1472,22 +1951,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -1497,12 +1988,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -1511,6 +2010,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1690,18 +2196,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1711,7 +2233,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1721,7 +2243,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1777,22 +2304,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1802,8 +2353,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1816,10 +2367,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -1939,22 +2497,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1964,8 +2546,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1978,10 +2560,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -2110,6 +2699,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2190,133 +2787,275 @@ constructor( class NewPlanPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) /** * For custom cadence: specifies the duration of the billing period in days or months. */ - @JsonProperty("billing_cycle_configuration") fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** An alias for the price. */ - @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - @JsonProperty("invoicing_cycle_configuration") fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun toBuilder() = Builder().from(this) + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - companion object { + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JvmStatic fun builder() = Builder() - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - class Builder { + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmSynthetic - internal fun from(newPlanPackagePrice: NewPlanPackagePrice) = apply { + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewPlanPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanPackagePrice: NewPlanPackagePrice) = apply { cadence = newPlanPackagePrice.cadence itemId = newPlanPackagePrice.itemId modelType = newPlanPackagePrice.modelType @@ -2336,17 +3075,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } @@ -2354,9 +3109,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -2365,13 +3119,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -2388,13 +3149,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -2404,10 +3173,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -2418,11 +3194,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -2430,22 +3211,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -2462,22 +3252,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -2487,12 +3289,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -2501,6 +3311,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2682,25 +3499,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would divide + * usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would divide * usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2710,8 +3554,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2722,7 +3566,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -2730,7 +3578,15 @@ constructor( * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { this.packageSize = packageSize } + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2791,22 +3647,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2816,8 +3696,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2830,10 +3710,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -2953,22 +3840,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2978,8 +3889,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2992,10 +3903,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -3124,6 +4042,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3204,129 +4130,271 @@ constructor( class NewPlanMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) /** * For custom cadence: specifies the duration of the billing period in days or months. */ - @JsonProperty("billing_cycle_configuration") fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** An alias for the price. */ - @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - @JsonProperty("invoicing_cycle_configuration") fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JsonAnyGetter + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_config") @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + fun _matrixConfig(): JsonField = matrixConfig - fun toBuilder() = Builder().from(this) + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - companion object { + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewPlanMatrixPrice = apply { + if (!validated) { + cadence() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { @JvmStatic fun builder() = Builder() } class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3350,27 +4418,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) + + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -3379,13 +4462,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -3402,13 +4492,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -3418,10 +4516,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -3432,11 +4537,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -3444,22 +4554,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -3476,22 +4595,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -3501,12 +4632,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -3515,6 +4654,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3643,29 +4789,63 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Default per unit rate for any usage not bucketed into a specified matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + /** * Default per unit rate for any usage not bucketed into a specified matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") fun matrixValues(): List = matrixValues + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3675,16 +4855,16 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -3692,28 +4872,60 @@ constructor( * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -3744,11 +4956,11 @@ constructor( "`defaultUnitAmount` is required but was not set" }, checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -3757,27 +4969,55 @@ constructor( class MatrixValue @JsonCreator private constructor( - @JsonProperty("dimension_values") private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("dimension_values") + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and + * an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For example, * ["region", "tier"] could be used to filter cloud usage by a cloud region and * an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3787,14 +5027,14 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() } @@ -3804,8 +5044,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -3815,11 +5063,24 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { add(dimensionValue) } + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -3848,7 +5109,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -3950,22 +5211,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3975,8 +5260,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3989,10 +5274,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -4112,22 +5404,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4137,8 +5453,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4151,10 +5467,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -4283,6 +5606,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4363,92 +5694,208 @@ constructor( class NewPlanTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -4456,12 +5903,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanTieredPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4471,21 +5942,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4509,17 +5982,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } @@ -4527,9 +6016,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -4538,13 +6026,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -4561,13 +6056,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -4577,10 +6080,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -4591,11 +6101,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -4603,22 +6118,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -4635,22 +6159,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -4660,12 +6196,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -4674,6 +6218,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4853,18 +6404,32 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4874,21 +6439,35 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Tiers for rating based on total usage quantities into the specified tier */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -4916,7 +6495,7 @@ constructor( fun build(): TieredConfig = TieredConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -4925,27 +6504,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") + + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4955,9 +6566,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -4970,15 +6581,25 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } /** * Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) /** * Exclusive tier ending value. If null, this is treated as the last tier @@ -4994,6 +6615,13 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** + * Exclusive tier ending value. If null, this is treated as the last tier + */ + fun lastUnit(lastUnit: JsonField) = apply { + this.lastUnit = lastUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5072,22 +6700,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5097,8 +6749,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5111,10 +6763,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5234,22 +6893,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5259,8 +6942,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5273,10 +6956,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5405,6 +7095,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5485,93 +7183,209 @@ constructor( class NewPlanTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_bps_config") - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -5579,12 +7393,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanTieredBpsPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5594,21 +7432,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5632,17 +7472,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } @@ -5650,9 +7506,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -5661,13 +7516,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -5684,13 +7546,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -5700,10 +7570,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -5714,11 +7591,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -5726,22 +7608,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -5758,22 +7649,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -5783,12 +7686,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -5797,6 +7708,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5978,7 +7896,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -5987,12 +7907,27 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified * tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified + * tiers + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6002,12 +7937,12 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -6015,14 +7950,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -6050,7 +8002,7 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -6059,32 +8011,70 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Inclusive tier starting value */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6094,10 +8084,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -6111,31 +8101,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -6213,22 +8218,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6238,8 +8267,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6252,10 +8281,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6375,22 +8411,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6400,8 +8460,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6414,10 +8474,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6546,9 +8613,17 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties - fun toBuilder() = Builder().from(this) + private var validated: Boolean = false - companion object { + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { @JvmStatic fun builder() = Builder() } @@ -6626,92 +8701,208 @@ constructor( class NewPlanBpsPrice @JsonCreator private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -6719,12 +8910,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6734,21 +8949,23 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6771,26 +8988,42 @@ constructor( additionalProperties = newPlanBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -6799,13 +9032,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -6822,13 +9062,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -6838,10 +9086,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -6852,11 +9107,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -6864,22 +9124,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -6896,22 +9165,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -6921,12 +9202,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -6935,6 +9224,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6982,23 +9278,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7008,8 +9326,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7020,17 +9338,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7218,22 +9543,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7243,8 +9592,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7257,10 +9606,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7380,22 +9736,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7405,8 +9785,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7419,10 +9799,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7551,6 +9938,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7631,92 +10026,208 @@ constructor( class NewPlanBulkBpsPrice @JsonCreator private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -7724,12 +10235,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7739,21 +10274,23 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7776,28 +10313,43 @@ constructor( additionalProperties = newPlanBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -7806,13 +10358,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -7829,13 +10388,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -7845,10 +10412,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -7859,11 +10433,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -7871,22 +10450,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -7903,22 +10491,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -7928,12 +10528,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -7942,6 +10550,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7991,7 +10606,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -8000,12 +10617,27 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier * based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier + * based on total volume + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8015,12 +10647,12 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -8028,14 +10660,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single + * tier based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -8063,7 +10712,7 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -8072,28 +10721,58 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8103,9 +10782,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8118,26 +10797,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8344,22 +11034,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8369,8 +11083,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8383,10 +11097,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8506,22 +11227,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8531,8 +11276,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8545,10 +11290,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8677,6 +11429,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8757,92 +11517,208 @@ constructor( class NewPlanBulkPrice @JsonCreator private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { - - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig - - /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence - - /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -8850,12 +11726,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8865,21 +11765,23 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8902,26 +11804,42 @@ constructor( additionalProperties = newPlanBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -8930,13 +11848,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -8953,13 +11878,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -8969,10 +11902,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -8983,11 +11923,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -8995,22 +11940,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -9027,22 +11981,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -9052,12 +12018,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -9066,6 +12040,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9113,18 +12094,32 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9134,21 +12129,35 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -9176,7 +12185,7 @@ constructor( fun build(): BulkConfig = BulkConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -9185,23 +12194,47 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9211,8 +12244,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9224,13 +12257,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) + /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = maximumUnits(maximumUnits as Double?) @@ -9242,6 +12279,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9449,22 +12491,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9474,8 +12540,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9488,10 +12554,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9611,22 +12684,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9636,8 +12733,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9650,10 +12747,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9782,6 +12886,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9862,95 +12974,211 @@ constructor( class NewPlanThresholdTotalAmountPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("threshold_total_amount_config") fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = thresholdTotalAmountConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -9958,12 +13186,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9973,21 +13225,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10017,27 +13272,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig( thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -10046,13 +13317,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -10069,13 +13347,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -10085,10 +13371,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -10099,11 +13392,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -10111,22 +13409,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -10143,22 +13450,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -10168,12 +13487,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -10182,6 +13509,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10371,6 +13705,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10440,22 +13782,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10465,8 +13831,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10479,10 +13845,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10602,22 +13975,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10627,8 +14024,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10641,10 +14038,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10773,6 +14177,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10853,131 +14265,272 @@ constructor( class NewPlanTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") - private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) /** * For custom cadence: specifies the duration of the billing period in days or months. */ - @JsonProperty("billing_cycle_configuration") fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** An alias for the price. */ - @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - @JsonProperty("invoicing_cycle_configuration") fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun toBuilder() = Builder().from(this) + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - companion object { + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JvmStatic fun builder() = Builder() + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_package_config") + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewPlanTieredPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() } class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11003,27 +14556,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -11032,13 +14601,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -11055,13 +14631,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -11071,10 +14655,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -11085,11 +14676,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -11097,22 +14693,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -11129,22 +14734,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -11154,12 +14771,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -11168,6 +14793,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -11357,6 +14989,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11425,22 +15065,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11450,8 +15114,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11464,10 +15128,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11587,22 +15258,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11612,8 +15307,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11626,10 +15321,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11758,6 +15460,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11838,135 +15548,278 @@ constructor( class NewPlanTieredWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) /** * For custom cadence: specifies the duration of the billing period in days or months. */ - @JsonProperty("billing_cycle_configuration") fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** An alias for the price. */ - @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - @JsonProperty("invoicing_cycle_configuration") fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun toBuilder() = Builder().from(this) + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - companion object { + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JvmStatic fun builder() = Builder() - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - class Builder { + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmSynthetic - internal fun from(newPlanTieredWithMinimumPrice: NewPlanTieredWithMinimumPrice) = + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewPlanTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanTieredWithMinimumPrice: NewPlanTieredWithMinimumPrice) = apply { cadence = newPlanTieredWithMinimumPrice.cadence itemId = newPlanTieredWithMinimumPrice.itemId @@ -11991,28 +15844,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -12021,13 +15888,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -12044,13 +15918,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -12060,10 +15942,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -12074,11 +15963,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -12086,22 +15980,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -12118,22 +16021,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -12143,12 +16058,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -12157,6 +16080,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -12346,6 +16276,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12414,22 +16352,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12439,8 +16401,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12453,10 +16415,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12576,22 +16545,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12601,8 +16594,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12615,10 +16608,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12747,6 +16747,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12827,139 +16835,280 @@ constructor( class NewPlanUnitWithPercentPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) /** * For custom cadence: specifies the duration of the billing period in days or months. */ - @JsonProperty("billing_cycle_configuration") fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) /** An alias for the price. */ - @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - @JsonProperty("invoicing_cycle_configuration") fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun toBuilder() = Builder().from(this) + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - companion object { + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JvmStatic fun builder() = Builder() - } + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - class Builder { + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var additionalProperties: MutableMap = mutableMapOf() + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId - @JvmSynthetic - internal fun from(newPlanUnitWithPercentPrice: NewPlanUnitWithPercentPrice) = - apply { - cadence = newPlanUnitWithPercentPrice.cadence - itemId = newPlanUnitWithPercentPrice.itemId - modelType = newPlanUnitWithPercentPrice.modelType + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + @JsonProperty("metadata") + @ExcludeMissing + fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewPlanUnitWithPercentPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newPlanUnitWithPercentPrice: NewPlanUnitWithPercentPrice) = + apply { + cadence = newPlanUnitWithPercentPrice.cadence + itemId = newPlanUnitWithPercentPrice.itemId + modelType = newPlanUnitWithPercentPrice.modelType name = newPlanUnitWithPercentPrice.name unitWithPercentConfig = newPlanUnitWithPercentPrice.unitWithPercentConfig billableMetricId = newPlanUnitWithPercentPrice.billableMetricId @@ -12979,27 +17128,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = apply { - this.unitWithPercentConfig = unitWithPercentConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = + apply { + this.unitWithPercentConfig = unitWithPercentConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -13008,13 +17173,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -13031,13 +17203,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -13047,10 +17227,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -13061,11 +17248,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -13073,22 +17265,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -13105,22 +17306,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -13130,12 +17343,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -13144,6 +17365,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13333,6 +17561,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13401,22 +17637,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13426,8 +17686,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13440,10 +17700,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13563,22 +17830,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13588,8 +17879,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13602,10 +17893,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13734,6 +18032,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13814,95 +18120,211 @@ constructor( class NewPlanPackageWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_with_allocation_config") fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = packageWithAllocationConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -13910,12 +18332,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13925,21 +18371,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13969,27 +18418,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -13998,13 +18463,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -14021,13 +18493,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -14037,10 +18517,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -14051,11 +18538,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -14063,22 +18555,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -14095,22 +18596,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -14120,12 +18633,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -14134,6 +18655,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -14323,6 +18851,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14392,22 +18928,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14417,8 +18977,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14431,10 +18991,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14554,22 +19121,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14579,8 +19170,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14593,10 +19184,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14725,6 +19323,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14780,119 +19386,236 @@ constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewPlanPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanTierWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - return /* spotless:off */ other is NewPlanPackageWithAllocationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewPlanPackageWithAllocationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewPlanTierWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_proration_config") - fun tieredWithProrationConfig(): TieredWithProrationConfig = tieredWithProrationConfig + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -14900,12 +19623,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanTierWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14915,21 +19662,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14958,27 +19707,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig( tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -14987,13 +19752,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -15010,13 +19782,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -15026,10 +19806,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -15040,11 +19827,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -15052,22 +19844,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -15084,22 +19885,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -15109,12 +19922,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -15123,6 +19944,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15312,6 +20140,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15381,22 +20217,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15406,8 +20266,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15420,10 +20280,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15543,22 +20410,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15568,8 +20459,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15582,10 +20473,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15714,6 +20612,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15777,111 +20683,228 @@ constructor( return true } - return /* spotless:off */ other is NewPlanTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewPlanTierWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanUnitWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewPlanTierWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewPlanUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -15889,12 +20912,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanUnitWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15904,21 +20951,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15947,28 +20996,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -15977,13 +21040,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -16000,13 +21070,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -16016,10 +21094,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -16030,11 +21115,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -16042,22 +21132,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -16074,22 +21173,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -16099,12 +21210,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -16113,6 +21232,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16302,6 +21428,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16370,22 +21504,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16395,8 +21553,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16409,10 +21567,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16532,22 +21697,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16557,8 +21746,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16571,10 +21760,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16703,6 +21899,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16766,111 +21970,228 @@ constructor( return true } - return /* spotless:off */ other is NewPlanUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewPlanUnitWithProrationPrice && cadence == other.cadence && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && currency == other.currency && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewPlanGroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, currency, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewPlanUnitWithProrationPrice{cadence=$cadence, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewPlanGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -16878,12 +22199,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanGroupedAllocationPrice = apply { + if (!validated) { + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16893,21 +22238,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16936,28 +22283,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -16966,13 +22327,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -16989,13 +22357,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -17005,10 +22381,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -17019,11 +22402,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -17031,22 +22419,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -17063,22 +22460,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -17088,12 +22497,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -17102,6 +22519,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -17240,6 +22664,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17359,22 +22791,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17384,8 +22840,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17398,10 +22854,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17521,22 +22984,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17546,8 +23033,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17560,10 +23047,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17692,6 +23186,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17768,99 +23270,216 @@ constructor( "NewPlanGroupedAllocationPrice{cadence=$cadence, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, currency=$currency, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - @NoAutoDetect - class NewPlanGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @NoAutoDetect + class NewPlanGroupedWithProratedMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence @JsonProperty("grouped_with_prorated_minimum_config") - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = groupedWithProratedMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -17868,12 +23487,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17883,22 +23526,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig? = + private var cadence: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17928,29 +23574,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -17959,13 +23621,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -17982,13 +23651,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -17998,10 +23675,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -18012,11 +23696,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -18024,22 +23713,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -18056,22 +23754,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -18081,12 +23791,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -18095,6 +23813,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -18233,6 +23958,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18355,22 +24088,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18380,8 +24137,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18394,10 +24151,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18517,22 +24281,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18542,8 +24330,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18556,10 +24344,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18688,6 +24483,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18768,95 +24571,212 @@ constructor( class NewPlanGroupedWithMeteredMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_metered_minimum_config") - private val groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") - @JsonProperty("grouped_with_metered_minimum_config") fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = groupedWithMeteredMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -18864,12 +24784,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanGroupedWithMeteredMinimumPrice = apply { + if (!validated) { + cadence() + groupedWithMeteredMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18879,21 +24823,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18923,27 +24871,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedWithMeteredMinimumConfig( groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -18952,13 +24916,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -18975,13 +24946,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -18991,10 +24970,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -19005,11 +24991,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -19017,22 +25008,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -19049,22 +25049,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -19074,12 +25086,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -19088,6 +25108,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19226,6 +25253,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19347,22 +25382,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19372,8 +25431,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19386,10 +25445,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19509,22 +25575,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19534,8 +25624,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19548,10 +25638,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19680,6 +25777,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19760,95 +25865,211 @@ constructor( class NewPlanMatrixWithDisplayNamePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), @JsonProperty("matrix_with_display_name_config") - private val matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("matrix_with_display_name_config") fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -19856,12 +26077,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanMatrixWithDisplayNamePrice = apply { + if (!validated) { + cadence() + itemId() + matrixWithDisplayNameConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19871,21 +26116,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19915,27 +26163,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } fun matrixWithDisplayNameConfig( matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -19944,13 +26208,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -19967,13 +26238,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -19983,10 +26262,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -19997,34 +26283,48 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: Optional) = currency(currency.orElse(null)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: Optional) = currency(currency.orElse(null)) + fun currency(currency: JsonField) = apply { this.currency = currency } /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -20041,22 +26341,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -20066,12 +26378,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -20080,6 +26400,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -20218,6 +26545,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20338,22 +26673,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20363,8 +26722,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20377,10 +26736,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20500,22 +26866,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20525,8 +26915,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20539,10 +26929,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20671,6 +27068,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20752,93 +27157,210 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -20846,12 +27368,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20861,21 +27407,23 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20904,28 +27452,42 @@ constructor( } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -20934,13 +27496,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -20957,13 +27526,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -20973,10 +27550,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -20987,11 +27571,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -20999,22 +27588,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -21031,22 +27629,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -21056,12 +27666,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -21070,6 +27688,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21127,6 +27752,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21327,22 +27960,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21352,8 +28009,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21366,10 +28023,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21489,22 +28153,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21514,8 +28202,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21528,10 +28216,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21660,6 +28355,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21740,95 +28443,211 @@ constructor( class NewPlanGroupedTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_tiered_package_config") - private val groupedTieredPackageConfig: GroupedTieredPackageConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") - @JsonProperty("grouped_tiered_package_config") fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this price + * is billed. + */ + fun currency(): Optional = Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = groupedTieredPackageConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this price * is billed. */ - @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -21836,12 +28655,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPlanGroupedTieredPackagePrice = apply { + if (!validated) { + cadence() + groupedTieredPackageConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21851,21 +28694,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedTieredPackageConfig: GroupedTieredPackageConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21895,27 +28741,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedTieredPackageConfig( groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -21924,13 +28786,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this @@ -21947,13 +28816,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -21963,10 +28840,17 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = @@ -21977,11 +28861,16 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -21989,22 +28878,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -22021,22 +28919,34 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. @@ -22046,12 +28956,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed * by setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -22060,6 +28978,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22198,6 +29123,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22318,22 +29251,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22343,8 +29300,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22357,10 +29314,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22480,22 +29444,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22505,8 +29493,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22519,10 +29507,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22651,6 +29646,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22745,6 +29748,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt index 6a883841..dad40693 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdFetchParams.kt @@ -7,6 +7,22 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch [plan](../guides/concepts##plan-and-price) details given an + * external_plan_id identifier. It returns information about the prices included in the plan and + * their configuration, as well as the product that the plan is attached to. + * + * If multiple plans are found to contain the specified external_plan_id, the active plans will take + * priority over archived ones, and among those, the endpoint will return the most recently created + * plan. + * + * ## Serialized prices + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given [Price](../guides/concepts#plan-and-price) object. The `model_type` field + * determines the key for the configuration object that is present. A detailed explanation of price + * types can be found in the [Price schema](../guides/concepts#plan-and-price). " + */ class PlanExternalPlanIdFetchParams constructor( private val externalPlanId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt index 48314c06..bca38781 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanExternalPlanIdUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing plan. + * + * Other fields on a customer are currently immutable. + */ class PlanExternalPlanIdUpdateParams constructor( private val otherExternalPlanId: String, @@ -39,12 +46,25 @@ constructor( */ fun metadata(): Optional = body.metadata() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * An optional user-defined ID for this plan resource, used throughout the system as an alias + * for this Plan. Use this field to identify a plan by an existing identifier in your system. + */ + fun _externalPlanId(): JsonField = body._externalPlanId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): PlanExternalPlanIdUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -62,31 +82,61 @@ constructor( class PlanExternalPlanIdUpdateBody @JsonCreator internal constructor( - @JsonProperty("external_plan_id") private val externalPlanId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your * system. */ @JsonProperty("external_plan_id") - fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PlanExternalPlanIdUpdateBody = apply { + if (!validated) { + externalPlanId() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -96,8 +146,8 @@ constructor( class Builder { - private var externalPlanId: String? = null - private var metadata: Metadata? = null + private var externalPlanId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -113,9 +163,8 @@ constructor( * alias for this Plan. Use this field to identify a plan by an existing identifier in * your system. */ - fun externalPlanId(externalPlanId: String?) = apply { - this.externalPlanId = externalPlanId - } + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -125,12 +174,21 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -139,6 +197,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -227,6 +292,15 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + body.externalPlanId(externalPlanId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -241,6 +315,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -339,25 +439,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): PlanExternalPlanIdUpdateParams = PlanExternalPlanIdUpdateParams( checkNotNull(otherExternalPlanId) { @@ -386,6 +467,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt index 5046e958..d166ce93 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanFetchParams.kt @@ -7,6 +7,23 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch [plan](../guides/concepts##plan-and-price) details given a plan + * identifier. It returns information about the prices included in the plan and their configuration, + * as well as the product that the plan is attached to. + * + * ## Serialized prices + * + * Orb supports a few different pricing models out of the box. Each of these models is serialized + * differently in a given [Price](../guides/concepts#plan-and-price) object. The `model_type` field + * determines the key for the configuration object that is present. A detailed explanation of price + * types can be found in the [Price schema](../guides/concepts#plan-and-price). + * + * ## Phases + * + * Orb supports plan phases, also known as contract ramps. For plans with phases, the serialized + * prices refer to all prices across all phases. + */ class PlanFetchParams constructor( private val planId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt index 5db830a7..00393917 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanListParams.kt @@ -14,6 +14,12 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all [plans](../guides/concepts##plan-and-price) for an account in + * a list format. The list of plans is ordered starting from the most recently created plan. The + * response also includes [`pagination_metadata`](../reference/pagination), which lets the caller + * retrieve the next page of results if they exist. + */ class PlanListParams constructor( private val createdAtGt: OffsetDateTime?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt index 224fbc77..ef85ef4f 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PlanUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,11 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint can be used to update the `external_plan_id`, and `metadata` of an existing plan. + * + * Other fields on a customer are currently immutable. + */ class PlanUpdateParams constructor( private val planId: String, @@ -39,12 +46,25 @@ constructor( */ fun metadata(): Optional = body.metadata() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * An optional user-defined ID for this plan resource, used throughout the system as an alias + * for this Plan. Use this field to identify a plan by an existing identifier in your system. + */ + fun _externalPlanId(): JsonField = body._externalPlanId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): PlanUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -62,31 +82,61 @@ constructor( class PlanUpdateBody @JsonCreator internal constructor( - @JsonProperty("external_plan_id") private val externalPlanId: String?, - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your * system. */ @JsonProperty("external_plan_id") - fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PlanUpdateBody = apply { + if (!validated) { + externalPlanId() + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -96,8 +146,8 @@ constructor( class Builder { - private var externalPlanId: String? = null - private var metadata: Metadata? = null + private var externalPlanId: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -112,9 +162,8 @@ constructor( * alias for this Plan. Use this field to identify a plan by an existing identifier in * your system. */ - fun externalPlanId(externalPlanId: String?) = apply { - this.externalPlanId = externalPlanId - } + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -124,12 +173,21 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -138,6 +196,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -223,6 +288,15 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in your + * system. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + body.externalPlanId(externalPlanId) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -237,6 +311,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -335,25 +435,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): PlanUpdateParams = PlanUpdateParams( checkNotNull(planId) { "`planId` is required but was not set" }, @@ -380,6 +461,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt index 50f89152..7019d5b1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Price.kt @@ -1137,64 +1137,86 @@ private constructor( fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - @JsonProperty("unit_config") @ExcludeMissing fun _unitConfig() = unitConfig + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig @JsonAnyGetter @ExcludeMissing @@ -1240,31 +1262,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var unitConfig: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1299,8 +1319,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -1317,8 +1340,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -1330,8 +1359,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -1341,27 +1373,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -1371,11 +1431,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -1395,11 +1461,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -1413,7 +1485,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -1450,29 +1529,39 @@ private constructor( fun build(): UnitPrice = UnitPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - unitConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(unitConfig) { "`unitConfig` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1490,7 +1579,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -1514,7 +1603,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1549,7 +1638,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -1588,9 +1681,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -1615,8 +1710,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1662,8 +1757,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1842,9 +1937,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -1869,8 +1966,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1915,8 +2012,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1957,9 +2056,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -1984,8 +2085,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2032,8 +2133,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2131,9 +2232,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -2158,8 +2259,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2201,8 +2302,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2255,10 +2356,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -2283,13 +2386,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -2306,7 +2409,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -2342,8 +2462,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2479,10 +2604,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -2507,13 +2634,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -2530,7 +2657,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -2566,8 +2710,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2713,7 +2862,9 @@ private constructor( fun unitAmount(): String = unitAmount.getRequired("unit_amount") /** Rate per unit of usage */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing @@ -2737,7 +2888,7 @@ private constructor( class Builder { - private var unitAmount: JsonField = JsonMissing.of() + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2776,7 +2927,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): UnitConfig = UnitConfig(unitAmount, additionalProperties.toImmutable()) + fun build(): UnitConfig = + UnitConfig( + checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -2953,64 +3108,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_config") @ExcludeMissing fun _packageConfig() = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -3056,31 +3233,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var packageConfig: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3115,8 +3290,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -3133,8 +3311,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -3146,8 +3330,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -3157,27 +3344,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -3187,11 +3402,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -3211,11 +3432,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -3236,7 +3463,14 @@ private constructor( this.packageConfig = packageConfig } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -3267,29 +3501,39 @@ private constructor( fun build(): PackagePrice = PackagePrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - packageConfig, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(packageConfig) { "`packageConfig` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3307,7 +3551,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -3331,7 +3575,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3366,7 +3610,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -3405,9 +3653,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -3432,8 +3682,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3479,8 +3729,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3659,9 +3909,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -3686,8 +3938,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3732,8 +3984,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3774,9 +4028,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -3801,8 +4057,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3849,8 +4105,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3948,9 +4204,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -3975,8 +4231,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4018,8 +4274,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4072,10 +4328,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -4100,13 +4358,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -4123,7 +4381,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -4159,8 +4434,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4296,10 +4576,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -4324,13 +4606,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -4347,7 +4629,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -4383,8 +4682,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4482,13 +4786,17 @@ private constructor( fun packageSize(): Long = packageSize.getRequired("package_size") /** A currency amount to rate usage by */ - @JsonProperty("package_amount") @ExcludeMissing fun _packageAmount() = packageAmount + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would divide * usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") @ExcludeMissing fun _packageSize() = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing @@ -4513,8 +4821,8 @@ private constructor( class Builder { - private var packageAmount: JsonField = JsonMissing.of() - private var packageSize: JsonField = JsonMissing.of() + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4571,8 +4879,10 @@ private constructor( fun build(): PackageConfig = PackageConfig( - packageAmount, - packageSize, + checkNotNull(packageAmount) { + "`packageAmount` is required but was not set" + }, + checkNotNull(packageSize) { "`packageSize` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4808,64 +5118,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("matrix_config") @ExcludeMissing fun _matrixConfig() = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -4911,31 +5243,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var matrixConfig: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var matrixConfig: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4970,8 +5300,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -4988,8 +5321,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -5001,8 +5340,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -5012,27 +5354,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -5048,11 +5418,17 @@ private constructor( this.matrixConfig = matrixConfig } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -5072,11 +5448,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -5090,7 +5472,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -5121,29 +5510,39 @@ private constructor( fun build(): MatrixPrice = MatrixPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - matrixConfig, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(matrixConfig) { "`matrixConfig` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5161,7 +5560,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -5185,7 +5584,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5220,7 +5619,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -5259,9 +5662,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -5286,8 +5691,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5333,8 +5738,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5513,9 +5918,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -5540,8 +5947,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5586,8 +5993,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5628,9 +6037,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -5655,8 +6066,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5703,8 +6114,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5802,9 +6213,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -5829,8 +6240,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5872,8 +6283,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5925,13 +6336,17 @@ private constructor( /** Default per unit rate for any usage not bucketed into a specified matrix_value */ @JsonProperty("default_unit_amount") @ExcludeMissing - fun _defaultUnitAmount() = defaultUnitAmount + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") @ExcludeMissing fun _matrixValues() = matrixValues + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing @@ -5957,16 +6372,16 @@ private constructor( class Builder { - private var defaultUnitAmount: JsonField = JsonMissing.of() - private var dimensions: JsonField> = JsonMissing.of() - private var matrixValues: JsonField> = JsonMissing.of() + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions - matrixValues = matrixConfig.matrixValues + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -5988,7 +6403,21 @@ private constructor( /** One or two event property values to evaluate matrix groups by */ fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** One or two event property values to evaluate matrix groups by */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ @@ -5997,7 +6426,21 @@ private constructor( /** Matrix values for specified matrix grouping keys */ fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** Matrix values for specified matrix grouping keys */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -6024,9 +6467,13 @@ private constructor( fun build(): MatrixConfig = MatrixConfig( - defaultUnitAmount, - dimensions.map { it.toImmutable() }, - matrixValues.map { it.toImmutable() }, + checkNotNull(defaultUnitAmount) { + "`defaultUnitAmount` is required but was not set" + }, + checkNotNull(dimensions) { "`dimensions` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -6063,10 +6510,12 @@ private constructor( */ @JsonProperty("dimension_values") @ExcludeMissing - fun _dimensionValues() = dimensionValues + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing @@ -6091,13 +6540,13 @@ private constructor( class Builder { - private var dimensionValues: JsonField> = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() } @@ -6116,7 +6565,25 @@ private constructor( * an instance tier. */ fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and + * an instance tier. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } /** Unit price for the specified dimension_values */ @@ -6151,8 +6618,11 @@ private constructor( fun build(): MatrixValue = MatrixValue( - dimensionValues.map { it.toImmutable() }, - unitAmount, + checkNotNull(dimensionValues) { + "`dimensionValues` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6223,10 +6693,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -6251,13 +6723,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -6274,7 +6746,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -6310,8 +6799,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -6447,10 +6941,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -6475,13 +6971,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -6498,7 +6994,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -6534,8 +7047,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -6822,64 +7340,86 @@ private constructor( fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - @JsonProperty("tiered_config") @ExcludeMissing fun _tieredConfig() = tieredConfig + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig @JsonAnyGetter @ExcludeMissing @@ -6925,31 +7465,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var tieredConfig: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6984,8 +7522,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -7002,8 +7543,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -7015,8 +7562,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -7026,27 +7576,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -7056,11 +7634,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -7080,11 +7664,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -7098,7 +7688,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -7135,29 +7732,39 @@ private constructor( fun build(): TieredPrice = TieredPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - tieredConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(tieredConfig) { "`tieredConfig` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7175,7 +7782,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -7199,7 +7806,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7234,7 +7841,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -7273,9 +7884,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -7300,8 +7913,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7347,8 +7960,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7527,9 +8140,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -7554,8 +8169,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7600,8 +8215,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7642,9 +8259,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -7669,8 +8288,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7717,8 +8336,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7816,9 +8435,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -7843,8 +8462,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7886,8 +8505,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -7940,10 +8559,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -7968,13 +8589,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -7991,7 +8612,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -8027,8 +8665,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -8164,10 +8807,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -8192,13 +8837,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -8215,7 +8860,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -8251,8 +8913,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -8398,7 +9065,7 @@ private constructor( fun tiers(): List = tiers.getRequired("tiers") /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers() = tiers + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing @@ -8422,12 +9089,12 @@ private constructor( class Builder { - private var tiers: JsonField> = JsonMissing.of() + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } @@ -8435,7 +9102,23 @@ private constructor( fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** Tiers for rating based on total usage quantities into the specified tier */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8460,7 +9143,11 @@ private constructor( } fun build(): TieredConfig = - TieredConfig(tiers.map { it.toImmutable() }, additionalProperties.toImmutable()) + TieredConfig( + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } @NoAutoDetect @@ -8491,13 +9178,19 @@ private constructor( Optional.ofNullable(lastUnit.getNullable("last_unit")) /** Inclusive tier starting value */ - @JsonProperty("first_unit") @ExcludeMissing fun _firstUnit() = firstUnit + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit /** Amount per unit */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Exclusive tier ending value. If null, this is treated as the last tier */ - @JsonProperty("last_unit") @ExcludeMissing fun _lastUnit() = lastUnit + @JsonProperty("last_unit") + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing @@ -8523,8 +9216,8 @@ private constructor( class Builder { - private var firstUnit: JsonField = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8553,7 +9246,15 @@ private constructor( } /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: Double) = lastUnit(JsonField.of(lastUnit)) + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun lastUnit(lastUnit: Optional) = + lastUnit(lastUnit.orElse(null) as Double?) /** Exclusive tier ending value. If null, this is treated as the last tier */ fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } @@ -8582,8 +9283,8 @@ private constructor( fun build(): Tier = Tier( - firstUnit, - unitAmount, + checkNotNull(firstUnit) { "`firstUnit` is required but was not set" }, + checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, lastUnit, additionalProperties.toImmutable(), ) @@ -8781,64 +9482,86 @@ private constructor( fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType - @JsonProperty("tiered_bps_config") @ExcludeMissing fun _tieredBpsConfig() = tieredBpsConfig + @JsonProperty("tiered_bps_config") + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig @JsonAnyGetter @ExcludeMissing @@ -8884,31 +9607,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var tieredBpsConfig: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredBpsConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8943,8 +9664,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -8961,8 +9685,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -8974,8 +9704,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -8985,27 +9718,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -9015,11 +9776,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -9039,11 +9806,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -9057,7 +9830,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -9095,29 +9875,41 @@ private constructor( fun build(): TieredBpsPrice = TieredBpsPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - tieredBpsConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(tieredBpsConfig) { + "`tieredBpsConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -9135,7 +9927,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -9159,7 +9951,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9194,7 +9986,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -9233,9 +10029,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -9260,8 +10058,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9307,8 +10105,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -9487,9 +10285,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -9514,8 +10314,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9560,8 +10360,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -9602,9 +10404,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -9629,8 +10433,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9677,8 +10481,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -9776,9 +10580,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -9803,8 +10607,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9846,8 +10650,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -9900,10 +10704,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -9928,13 +10734,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -9951,7 +10757,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -9987,8 +10810,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -10124,10 +10952,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -10152,13 +10982,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -10175,7 +11005,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -10211,8 +11058,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -10362,7 +11214,7 @@ private constructor( /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers() = tiers + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing @@ -10386,12 +11238,12 @@ private constructor( class Builder { - private var tiers: JsonField> = JsonMissing.of() + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -10405,7 +11257,26 @@ private constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified * tiers */ - fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified + * tiers + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10431,7 +11302,8 @@ private constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - tiers.map { it.toImmutable() }, + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -10471,18 +11343,22 @@ private constructor( Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) /** Per-event basis point rate */ - @JsonProperty("bps") @ExcludeMissing fun _bps() = bps + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") @ExcludeMissing - fun _perUnitMaximum() = perUnitMaximum + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing @@ -10509,8 +11385,8 @@ private constructor( class Builder { - private var bps: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null private var maximumAmount: JsonField = JsonMissing.of() private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10540,8 +11416,12 @@ private constructor( } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: JsonField) = apply { @@ -10549,8 +11429,12 @@ private constructor( } /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String) = - perUnitMaximum(JsonField.of(perUnitMaximum)) + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: Optional) = + perUnitMaximum(perUnitMaximum.orElse(null)) /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: JsonField) = apply { @@ -10581,8 +11465,10 @@ private constructor( fun build(): Tier = Tier( - bps, - minimumAmount, + checkNotNull(bps) { "`bps` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, maximumAmount, perUnitMaximum, additionalProperties.toImmutable(), @@ -10781,64 +11667,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("bps_config") @ExcludeMissing fun _bpsConfig() = bpsConfig + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -10884,31 +11792,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var bpsConfig: JsonField = JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10943,8 +11849,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -10965,8 +11874,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -10978,8 +11893,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -10989,27 +11907,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -11019,11 +11965,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -11043,11 +11995,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -11061,7 +12019,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -11092,29 +12057,39 @@ private constructor( fun build(): BpsPrice = BpsPrice( - id, - billableMetric, - billingCycleConfiguration, - bpsConfig, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(bpsConfig) { "`bpsConfig` is required but was not set" }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -11132,7 +12107,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -11156,7 +12131,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11191,7 +12166,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -11230,9 +12209,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -11257,8 +12238,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11304,8 +12285,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -11407,10 +12388,12 @@ private constructor( Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) /** Basis point take rate per event */ - @JsonProperty("bps") @ExcludeMissing fun _bps() = bps + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ - @JsonProperty("per_unit_maximum") @ExcludeMissing fun _perUnitMaximum() = perUnitMaximum + @JsonProperty("per_unit_maximum") + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing @@ -11435,7 +12418,7 @@ private constructor( class Builder { - private var bps: JsonField = JsonMissing.of() + private var bps: JsonField? = null private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11453,8 +12436,12 @@ private constructor( fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String) = - perUnitMaximum(JsonField.of(perUnitMaximum)) + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: Optional) = + perUnitMaximum(perUnitMaximum.orElse(null)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: JsonField) = apply { @@ -11485,7 +12472,7 @@ private constructor( fun build(): BpsConfig = BpsConfig( - bps, + checkNotNull(bps) { "`bps` is required but was not set" }, perUnitMaximum, additionalProperties.toImmutable(), ) @@ -11608,9 +12595,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -11635,8 +12624,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11681,8 +12670,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -11723,9 +12714,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -11750,8 +12743,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11798,8 +12791,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -11897,9 +12890,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -11924,8 +12917,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11967,8 +12960,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -12021,10 +13014,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -12049,13 +13044,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -12072,7 +13067,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -12108,8 +13120,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -12245,10 +13262,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -12273,13 +13292,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -12296,7 +13315,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -12332,8 +13368,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -12620,64 +13661,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("bulk_bps_config") @ExcludeMissing fun _bulkBpsConfig() = bulkBpsConfig + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -12723,31 +13786,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var bulkBpsConfig: JsonField = JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12782,8 +13843,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -12807,8 +13871,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -12820,8 +13890,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -12831,27 +13904,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -12861,11 +13962,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -12885,11 +13992,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -12903,7 +14016,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -12934,29 +14054,39 @@ private constructor( fun build(): BulkBpsPrice = BulkBpsPrice( - id, - billableMetric, - billingCycleConfiguration, - bulkBpsConfig, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(bulkBpsConfig) { "`bulkBpsConfig` is required but was not set" }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -12974,7 +14104,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -12998,7 +14128,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13033,7 +14163,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -13072,9 +14206,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -13099,8 +14235,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13146,8 +14282,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -13248,7 +14384,7 @@ private constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier * based on total volume */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers() = tiers + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing @@ -13272,12 +14408,12 @@ private constructor( class Builder { - private var tiers: JsonField> = JsonMissing.of() + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -13291,7 +14427,26 @@ private constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier * based on total volume */ - fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier + * based on total volume + */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13317,7 +14472,8 @@ private constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - tiers.map { it.toImmutable() }, + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -13351,15 +14507,17 @@ private constructor( Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) /** Basis points to rate on */ - @JsonProperty("bps") @ExcludeMissing fun _bps() = bps + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") @ExcludeMissing - fun _perUnitMaximum() = perUnitMaximum + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing @@ -13385,7 +14543,7 @@ private constructor( class Builder { - private var bps: JsonField = JsonMissing.of() + private var bps: JsonField? = null private var maximumAmount: JsonField = JsonMissing.of() private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -13405,8 +14563,12 @@ private constructor( fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String) = - maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: JsonField) = apply { @@ -13414,8 +14576,12 @@ private constructor( } /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String) = - perUnitMaximum(JsonField.of(perUnitMaximum)) + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: Optional) = + perUnitMaximum(perUnitMaximum.orElse(null)) /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: JsonField) = apply { @@ -13446,7 +14612,7 @@ private constructor( fun build(): Tier = Tier( - bps, + checkNotNull(bps) { "`bps` is required but was not set" }, maximumAmount, perUnitMaximum, additionalProperties.toImmutable(), @@ -13588,9 +14754,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -13615,8 +14783,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13661,8 +14829,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -13703,9 +14873,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -13730,8 +14902,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13778,8 +14950,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -13877,9 +15049,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -13904,8 +15076,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13947,8 +15119,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -14001,10 +15173,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -14029,13 +15203,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -14052,7 +15226,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -14088,8 +15279,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -14225,10 +15421,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -14253,13 +15451,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -14276,7 +15474,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -14312,8 +15527,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -14600,64 +15820,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("bulk_config") @ExcludeMissing fun _bulkConfig() = bulkConfig + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -14703,31 +15945,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var bulkConfig: JsonField = JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14762,8 +16002,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -14786,8 +16029,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -14799,8 +16048,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -14810,27 +16062,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -14840,11 +16120,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -14864,11 +16150,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -14882,7 +16174,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -14913,29 +16212,39 @@ private constructor( fun build(): BulkPrice = BulkPrice( - id, - billableMetric, - billingCycleConfiguration, - bulkConfig, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(bulkConfig) { "`bulkConfig` is required but was not set" }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -14953,7 +16262,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -14977,7 +16286,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15012,7 +16321,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -15051,9 +16364,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -15078,8 +16393,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15125,8 +16440,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -15221,7 +16536,7 @@ private constructor( fun tiers(): List = tiers.getRequired("tiers") /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") @ExcludeMissing fun _tiers() = tiers + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing @@ -15245,12 +16560,12 @@ private constructor( class Builder { - private var tiers: JsonField> = JsonMissing.of() + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } @@ -15258,7 +16573,23 @@ private constructor( fun tiers(tiers: List) = tiers(JsonField.of(tiers)) /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: JsonField>) = apply { this.tiers = tiers } + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } + + /** Bulk tiers for rating based on total usage volume */ + fun addTier(tier: Tier) = apply { + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -15283,7 +16614,11 @@ private constructor( } fun build(): BulkConfig = - BulkConfig(tiers.map { it.toImmutable() }, additionalProperties.toImmutable()) + BulkConfig( + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } @NoAutoDetect @@ -15308,10 +16643,14 @@ private constructor( Optional.ofNullable(maximumUnits.getNullable("maximum_units")) /** Amount per unit */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ - @JsonProperty("maximum_units") @ExcludeMissing fun _maximumUnits() = maximumUnits + @JsonProperty("maximum_units") + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing @@ -15336,7 +16675,7 @@ private constructor( class Builder { - private var unitAmount: JsonField = JsonMissing.of() + private var unitAmount: JsonField? = null private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -15356,8 +16695,16 @@ private constructor( } /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double) = - maximumUnits(JsonField.of(maximumUnits)) + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) + + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: Double) = maximumUnits(maximumUnits as Double?) + + /** Upper bound for this tier */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun maximumUnits(maximumUnits: Optional) = + maximumUnits(maximumUnits.orElse(null) as Double?) /** Upper bound for this tier */ fun maximumUnits(maximumUnits: JsonField) = apply { @@ -15388,7 +16735,7 @@ private constructor( fun build(): Tier = Tier( - unitAmount, + checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, maximumUnits, additionalProperties.toImmutable(), ) @@ -15529,9 +16876,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -15556,8 +16905,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15602,8 +16951,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -15644,9 +16995,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -15671,8 +17024,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15719,8 +17072,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -15818,9 +17171,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -15845,8 +17198,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15888,8 +17241,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -15942,10 +17295,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -15970,13 +17325,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -15993,7 +17348,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -16029,8 +17401,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -16166,10 +17543,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -16194,13 +17573,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -16217,7 +17596,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -16253,8 +17649,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -16543,66 +17944,87 @@ private constructor( fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("threshold_total_amount_config") @ExcludeMissing - fun _thresholdTotalAmountConfig() = thresholdTotalAmountConfig + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig @JsonAnyGetter @ExcludeMissing @@ -16648,32 +18070,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var thresholdTotalAmountConfig: JsonField = - JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16708,8 +18127,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -16726,8 +18148,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -16739,8 +18167,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -16750,27 +18181,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -16780,11 +18239,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -16804,11 +18269,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -16822,7 +18293,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -16860,29 +18338,41 @@ private constructor( fun build(): ThresholdTotalAmountPrice = ThresholdTotalAmountPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - thresholdTotalAmountConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(thresholdTotalAmountConfig) { + "`thresholdTotalAmountConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -16900,7 +18390,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -16924,7 +18414,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16959,7 +18449,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -16998,9 +18492,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -17025,8 +18521,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17072,8 +18568,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -17252,9 +18748,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -17279,8 +18777,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17325,8 +18823,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -17367,9 +18867,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -17394,8 +18896,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17442,8 +18944,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -17541,9 +19043,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -17568,8 +19070,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17611,8 +19113,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -17665,10 +19167,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -17693,13 +19197,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -17716,7 +19220,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -17752,8 +19273,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -17889,10 +19415,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -17917,13 +19445,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -17940,7 +19468,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -17976,8 +19521,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -18346,66 +19896,86 @@ private constructor( fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig.getRequired("tiered_package_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("tiered_package_config") @ExcludeMissing - fun _tieredPackageConfig() = tieredPackageConfig + fun _tieredPackageConfig(): JsonField = tieredPackageConfig @JsonAnyGetter @ExcludeMissing @@ -18451,31 +20021,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var tieredPackageConfig: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredPackageConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18510,8 +20078,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -18528,8 +20099,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -18541,8 +20118,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -18552,27 +20132,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -18582,11 +20190,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -18606,11 +20220,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -18624,7 +20244,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -18662,29 +20289,41 @@ private constructor( fun build(): TieredPackagePrice = TieredPackagePrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - tieredPackageConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(tieredPackageConfig) { + "`tieredPackageConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -18702,7 +20341,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -18726,7 +20365,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18761,7 +20400,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -18800,9 +20443,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -18827,8 +20472,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18874,8 +20519,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -19054,9 +20699,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -19081,8 +20728,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19127,8 +20774,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -19169,9 +20818,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -19196,8 +20847,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19244,8 +20895,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -19343,9 +20994,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -19370,8 +21021,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19413,8 +21064,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -19467,10 +21118,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -19495,13 +21148,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -19518,7 +21171,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -19554,8 +21224,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -19691,10 +21366,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -19719,13 +21396,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -19742,7 +21419,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -19778,8 +21472,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -20147,66 +21846,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("grouped_tiered_config") @ExcludeMissing - fun _groupedTieredConfig() = groupedTieredConfig + fun _groupedTieredConfig(): JsonField = groupedTieredConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -20252,31 +21971,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var groupedTieredConfig: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20311,8 +22028,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -20329,8 +22049,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -20342,8 +22068,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -20353,19 +22082,43 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity @@ -20379,8 +22132,12 @@ private constructor( } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -20390,11 +22147,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -20414,11 +22177,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -20432,7 +22201,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -20463,29 +22239,41 @@ private constructor( fun build(): GroupedTieredPrice = GroupedTieredPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedTieredConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(groupedTieredConfig) { + "`groupedTieredConfig` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -20503,7 +22291,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -20527,7 +22315,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20562,7 +22350,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -20601,9 +22393,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -20628,8 +22422,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20675,8 +22469,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -20855,9 +22649,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -20882,8 +22678,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20928,8 +22724,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -21050,9 +22848,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -21077,8 +22877,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21125,8 +22925,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -21224,9 +23024,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -21251,8 +23051,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21294,8 +23094,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -21348,10 +23148,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -21376,13 +23178,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -21399,7 +23201,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -21435,8 +23254,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -21572,10 +23396,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -21600,13 +23426,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -21623,7 +23449,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -21659,8 +23502,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -21948,66 +23796,86 @@ private constructor( fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("tiered_with_minimum_config") @ExcludeMissing - fun _tieredWithMinimumConfig() = tieredWithMinimumConfig + fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig @JsonAnyGetter @ExcludeMissing @@ -22053,32 +23921,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var tieredWithMinimumConfig: JsonField = - JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22113,8 +23978,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -22131,8 +23999,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -22144,8 +24018,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -22155,27 +24032,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -22185,11 +24090,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -22209,11 +24120,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -22227,7 +24144,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -22265,29 +24189,41 @@ private constructor( fun build(): TieredWithMinimumPrice = TieredWithMinimumPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - tieredWithMinimumConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(tieredWithMinimumConfig) { + "`tieredWithMinimumConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -22305,7 +24241,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -22329,7 +24265,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22364,7 +24300,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -22403,9 +24343,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -22430,8 +24372,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22477,8 +24419,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -22657,9 +24599,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -22684,8 +24628,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22730,8 +24674,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -22772,9 +24718,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -22799,8 +24747,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22847,8 +24795,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -22946,9 +24894,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -22973,8 +24921,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23016,8 +24964,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -23070,10 +25018,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -23098,13 +25048,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -23121,7 +25071,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -23157,8 +25124,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -23294,10 +25266,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -23322,13 +25296,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -23345,7 +25319,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -23381,8 +25372,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -23752,66 +25748,87 @@ private constructor( fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("tiered_package_with_minimum_config") @ExcludeMissing - fun _tieredPackageWithMinimumConfig() = tieredPackageWithMinimumConfig + fun _tieredPackageWithMinimumConfig(): JsonField = + tieredPackageWithMinimumConfig @JsonAnyGetter @ExcludeMissing @@ -23857,32 +25874,30 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var tieredPackageWithMinimumConfig: JsonField = - JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredPackageWithMinimumConfig: JsonField? = + null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23922,8 +25937,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -23940,8 +25958,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -23953,8 +25977,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -23964,27 +25991,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -23994,11 +26049,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -24018,11 +26079,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -24036,7 +26103,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -24075,29 +26149,41 @@ private constructor( fun build(): TieredPackageWithMinimumPrice = TieredPackageWithMinimumPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - tieredPackageWithMinimumConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(tieredPackageWithMinimumConfig) { + "`tieredPackageWithMinimumConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -24115,7 +26201,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -24139,7 +26225,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24174,7 +26260,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -24213,9 +26303,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -24240,8 +26332,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24287,8 +26379,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -24467,9 +26559,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -24494,8 +26588,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24540,8 +26634,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -24582,9 +26678,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -24609,8 +26707,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24657,8 +26755,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -24756,9 +26854,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -24783,8 +26881,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24826,8 +26924,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -24880,10 +26978,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -24908,13 +27008,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -24931,7 +27031,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -24967,8 +27084,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -25104,10 +27226,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -25132,13 +27256,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -25155,7 +27279,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -25191,8 +27332,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -25563,66 +27709,87 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("package_with_allocation_config") @ExcludeMissing - fun _packageWithAllocationConfig() = packageWithAllocationConfig + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -25668,32 +27835,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var packageWithAllocationConfig: JsonField = - JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -25729,8 +27893,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -25747,8 +27914,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -25760,8 +27933,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -25771,27 +27947,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -25801,11 +28005,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -25825,11 +28035,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -25851,7 +28067,14 @@ private constructor( packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -25882,29 +28105,41 @@ private constructor( fun build(): PackageWithAllocationPrice = PackageWithAllocationPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - packageWithAllocationConfig, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(packageWithAllocationConfig) { + "`packageWithAllocationConfig` is required but was not set" + }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -25922,7 +28157,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -25946,7 +28181,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -25981,7 +28216,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -26020,9 +28259,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -26047,8 +28288,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26094,8 +28335,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -26274,9 +28515,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -26301,8 +28544,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26347,8 +28590,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -26389,9 +28634,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -26416,8 +28663,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26464,8 +28711,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -26563,9 +28810,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -26590,8 +28837,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26633,8 +28880,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -26687,10 +28934,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -26715,13 +28964,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -26738,7 +28987,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -26774,8 +29040,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -26911,10 +29182,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -26939,13 +29212,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -26962,7 +29235,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -26998,8 +29288,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -27369,66 +29664,86 @@ private constructor( fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig.getRequired("unit_with_percent_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("unit_with_percent_config") @ExcludeMissing - fun _unitWithPercentConfig() = unitWithPercentConfig + fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig @JsonAnyGetter @ExcludeMissing @@ -27474,31 +29789,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var unitWithPercentConfig: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitWithPercentConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27533,8 +29846,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -27551,8 +29867,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -27564,8 +29886,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -27575,27 +29900,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -27605,11 +29958,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -27629,11 +29988,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -27647,7 +30012,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -27686,29 +30058,41 @@ private constructor( fun build(): UnitWithPercentPrice = UnitWithPercentPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - unitWithPercentConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(unitWithPercentConfig) { + "`unitWithPercentConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -27726,7 +30110,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -27750,7 +30134,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27785,7 +30169,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -27824,9 +30212,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -27851,8 +30241,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27898,8 +30288,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -28078,9 +30468,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -28105,8 +30497,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -28151,8 +30543,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -28193,9 +30587,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -28220,8 +30616,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -28268,8 +30664,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -28367,9 +30763,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -28394,8 +30790,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -28437,8 +30833,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -28491,10 +30887,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -28519,13 +30917,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -28542,7 +30940,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -28578,8 +30993,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -28715,10 +31135,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -28743,13 +31165,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -28766,7 +31188,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -28802,8 +31241,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -29172,66 +31616,87 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item @JsonProperty("matrix_with_allocation_config") @ExcludeMissing - fun _matrixWithAllocationConfig() = matrixWithAllocationConfig + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -29277,32 +31742,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var matrixWithAllocationConfig: JsonField = - JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var matrixWithAllocationConfig: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29337,8 +31799,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -29355,8 +31820,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -29368,8 +31839,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -29379,27 +31853,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -29416,11 +31918,17 @@ private constructor( matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -29440,11 +31948,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -29458,7 +31972,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -29489,29 +32010,41 @@ private constructor( fun build(): MatrixWithAllocationPrice = MatrixWithAllocationPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - matrixWithAllocationConfig, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(matrixWithAllocationConfig) { + "`matrixWithAllocationConfig` is required but was not set" + }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -29529,7 +32062,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -29553,7 +32086,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29588,7 +32121,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -29627,9 +32164,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -29654,8 +32193,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29701,8 +32240,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -29881,9 +32420,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -29908,8 +32449,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29954,8 +32495,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -29996,9 +32539,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -30023,8 +32568,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -30071,8 +32616,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -30170,9 +32715,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -30197,8 +32742,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -30240,8 +32785,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -30297,18 +32842,24 @@ private constructor( fun matrixValues(): List = matrixValues.getRequired("matrix_values") /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") @ExcludeMissing fun _allocation() = allocation + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation /** Default per unit rate for any usage not bucketed into a specified matrix_value */ @JsonProperty("default_unit_amount") @ExcludeMissing - fun _defaultUnitAmount() = defaultUnitAmount + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") @ExcludeMissing fun _dimensions() = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") @ExcludeMissing fun _matrixValues() = matrixValues + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing @@ -30335,18 +32886,19 @@ private constructor( class Builder { - private var allocation: JsonField = JsonMissing.of() - private var defaultUnitAmount: JsonField = JsonMissing.of() - private var dimensions: JsonField> = JsonMissing.of() - private var matrixValues: JsonField> = JsonMissing.of() + private var allocation: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = apply { allocation = matrixWithAllocationConfig.allocation defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - dimensions = matrixWithAllocationConfig.dimensions - matrixValues = matrixWithAllocationConfig.matrixValues + dimensions = matrixWithAllocationConfig.dimensions.map { it.toMutableList() } + matrixValues = + matrixWithAllocationConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixWithAllocationConfig.additionalProperties.toMutableMap() } @@ -30377,7 +32929,21 @@ private constructor( /** One or two event property values to evaluate matrix groups by */ fun dimensions(dimensions: JsonField>) = apply { - this.dimensions = dimensions + this.dimensions = dimensions.map { it.toMutableList() } + } + + /** One or two event property values to evaluate matrix groups by */ + fun addDimension(dimension: String) = apply { + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ @@ -30386,7 +32952,21 @@ private constructor( /** Matrix values for specified matrix grouping keys */ fun matrixValues(matrixValues: JsonField>) = apply { - this.matrixValues = matrixValues + this.matrixValues = matrixValues.map { it.toMutableList() } + } + + /** Matrix values for specified matrix grouping keys */ + fun addMatrixValue(matrixValue: MatrixValue) = apply { + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -30413,10 +32993,14 @@ private constructor( fun build(): MatrixWithAllocationConfig = MatrixWithAllocationConfig( - allocation, - defaultUnitAmount, - dimensions.map { it.toImmutable() }, - matrixValues.map { it.toImmutable() }, + checkNotNull(allocation) { "`allocation` is required but was not set" }, + checkNotNull(defaultUnitAmount) { + "`defaultUnitAmount` is required but was not set" + }, + checkNotNull(dimensions) { "`dimensions` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -30453,10 +33037,12 @@ private constructor( */ @JsonProperty("dimension_values") @ExcludeMissing - fun _dimensionValues() = dimensionValues + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") @ExcludeMissing fun _unitAmount() = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing @@ -30481,13 +33067,13 @@ private constructor( class Builder { - private var dimensionValues: JsonField> = JsonMissing.of() - private var unitAmount: JsonField = JsonMissing.of() + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() } @@ -30506,7 +33092,25 @@ private constructor( * an instance tier. */ fun dimensionValues(dimensionValues: JsonField>) = apply { - this.dimensionValues = dimensionValues + this.dimensionValues = dimensionValues.map { it.toMutableList() } + } + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and + * an instance tier. + */ + fun addDimensionValue(dimensionValue: String) = apply { + dimensionValues = + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } /** Unit price for the specified dimension_values */ @@ -30541,8 +33145,11 @@ private constructor( fun build(): MatrixValue = MatrixValue( - dimensionValues.map { it.toImmutable() }, - unitAmount, + checkNotNull(dimensionValues) { + "`dimensionValues` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -30613,10 +33220,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -30641,13 +33250,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -30664,7 +33273,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -30700,8 +33326,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -30837,10 +33468,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -30865,13 +33498,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -30888,7 +33521,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -30924,8 +33574,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -31214,66 +33869,87 @@ private constructor( fun tieredWithProrationConfig(): TieredWithProrationConfig = tieredWithProrationConfig.getRequired("tiered_with_proration_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("tiered_with_proration_config") @ExcludeMissing - fun _tieredWithProrationConfig() = tieredWithProrationConfig + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig @JsonAnyGetter @ExcludeMissing @@ -31319,32 +33995,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var tieredWithProrationConfig: JsonField = - JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var tieredWithProrationConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31379,8 +34052,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -31397,8 +34073,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -31410,8 +34092,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -31421,27 +34106,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -31451,11 +34164,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -31475,11 +34194,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -31493,7 +34218,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -31531,29 +34263,41 @@ private constructor( fun build(): TieredWithProrationPrice = TieredWithProrationPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - tieredWithProrationConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(tieredWithProrationConfig) { + "`tieredWithProrationConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -31571,7 +34315,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -31595,7 +34339,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31630,7 +34374,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -31669,9 +34417,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -31696,8 +34446,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31743,8 +34493,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -31923,9 +34673,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -31950,8 +34702,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31996,8 +34748,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -32038,9 +34792,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -32065,8 +34821,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -32113,8 +34869,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -32212,9 +34968,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -32239,8 +34995,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -32282,8 +35038,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -32336,10 +35092,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -32364,13 +35122,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -32387,7 +35145,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -32423,8 +35198,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -32560,10 +35340,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -32588,13 +35370,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -32611,7 +35393,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -32647,8 +35446,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -33017,66 +35821,86 @@ private constructor( fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig.getRequired("unit_with_proration_config") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonProperty("unit_with_proration_config") @ExcludeMissing - fun _unitWithProrationConfig() = unitWithProrationConfig + fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig @JsonAnyGetter @ExcludeMissing @@ -33122,32 +35946,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() - private var unitWithProrationConfig: JsonField = - JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null + private var unitWithProrationConfig: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33182,8 +36003,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -33200,8 +36024,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -33213,8 +36043,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -33224,27 +36057,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -33254,11 +36115,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -33278,11 +36145,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -33296,7 +36169,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -33334,29 +36214,41 @@ private constructor( fun build(): UnitWithProrationPrice = UnitWithProrationPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, - unitWithProrationConfig, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, + checkNotNull(unitWithProrationConfig) { + "`unitWithProrationConfig` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -33374,7 +36266,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -33398,7 +36290,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33433,7 +36325,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -33472,9 +36368,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -33499,8 +36397,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33546,8 +36444,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -33726,9 +36624,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -33753,8 +36653,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33799,8 +36699,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -33841,9 +36743,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -33868,8 +36772,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33916,8 +36820,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -34015,9 +36919,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -34042,8 +36946,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -34085,8 +36989,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -34139,10 +37043,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -34167,13 +37073,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -34190,7 +37096,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -34226,8 +37149,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -34363,10 +37291,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -34391,13 +37321,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -34414,7 +37344,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -34450,8 +37397,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -34820,66 +37772,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("grouped_allocation_config") @ExcludeMissing - fun _groupedAllocationConfig() = groupedAllocationConfig + fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -34925,32 +37897,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var groupedAllocationConfig: JsonField = - JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -34985,8 +37954,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -35003,8 +37975,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -35016,8 +37994,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -35027,19 +38008,43 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity @@ -35053,8 +38058,12 @@ private constructor( ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -35064,11 +38073,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -35088,11 +38103,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -35106,7 +38127,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -35137,29 +38165,41 @@ private constructor( fun build(): GroupedAllocationPrice = GroupedAllocationPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedAllocationConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(groupedAllocationConfig) { + "`groupedAllocationConfig` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -35177,7 +38217,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -35201,7 +38241,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35236,7 +38276,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -35275,9 +38319,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -35302,8 +38348,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35349,8 +38395,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -35529,9 +38575,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -35556,8 +38604,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35602,8 +38650,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -35725,9 +38775,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -35752,8 +38804,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35800,8 +38852,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -35899,9 +38951,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -35926,8 +38978,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35969,8 +39021,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -36023,10 +39075,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -36051,13 +39105,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -36074,7 +39128,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -36110,8 +39181,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -36247,10 +39323,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -36275,13 +39353,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -36298,7 +39376,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -36334,8 +39429,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -36624,66 +39724,87 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("grouped_with_prorated_minimum_config") @ExcludeMissing - fun _groupedWithProratedMinimumConfig() = groupedWithProratedMinimumConfig + fun _groupedWithProratedMinimumConfig(): JsonField = + groupedWithProratedMinimumConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -36729,33 +39850,31 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null private var groupedWithProratedMinimumConfig: - JsonField = - JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + JsonField? = + null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -36795,8 +39914,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -36813,8 +39935,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -36826,8 +39954,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -36837,19 +39968,43 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity @@ -36864,8 +40019,12 @@ private constructor( ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -36875,11 +40034,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -36899,11 +40064,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -36917,7 +40088,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -36948,29 +40126,41 @@ private constructor( fun build(): GroupedWithProratedMinimumPrice = GroupedWithProratedMinimumPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedWithProratedMinimumConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(groupedWithProratedMinimumConfig) { + "`groupedWithProratedMinimumConfig` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -36988,7 +40178,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -37012,7 +40202,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37047,7 +40237,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -37086,9 +40280,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -37113,8 +40309,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37160,8 +40356,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -37340,9 +40536,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -37367,8 +40565,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37413,8 +40611,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -37538,9 +40738,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -37565,8 +40767,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37613,8 +40815,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -37712,9 +40914,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -37739,8 +40941,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37782,8 +40984,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -37836,10 +41038,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -37864,13 +41068,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -37887,7 +41091,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -37923,8 +41144,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -38060,10 +41286,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -38088,13 +41316,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -38111,7 +41339,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -38147,8 +41392,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -38437,66 +41687,87 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("grouped_with_metered_minimum_config") @ExcludeMissing - fun _groupedWithMeteredMinimumConfig() = groupedWithMeteredMinimumConfig + fun _groupedWithMeteredMinimumConfig(): JsonField = + groupedWithMeteredMinimumConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -38542,33 +41813,31 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null private var groupedWithMeteredMinimumConfig: - JsonField = - JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + JsonField? = + null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -38608,8 +41877,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -38626,8 +41898,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -38639,8 +41917,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -38650,19 +41931,43 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity @@ -38677,8 +41982,12 @@ private constructor( ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -38688,11 +41997,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -38712,11 +42027,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -38730,7 +42051,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -38761,29 +42089,41 @@ private constructor( fun build(): GroupedWithMeteredMinimumPrice = GroupedWithMeteredMinimumPrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedWithMeteredMinimumConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(groupedWithMeteredMinimumConfig) { + "`groupedWithMeteredMinimumConfig` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -38801,7 +42141,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -38825,7 +42165,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -38860,7 +42200,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -38899,9 +42243,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -38926,8 +42272,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -38973,8 +42319,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -39153,9 +42499,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -39180,8 +42528,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -39226,8 +42574,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -39351,9 +42701,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -39378,8 +42730,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -39426,8 +42778,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -39525,9 +42877,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -39552,8 +42904,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -39595,8 +42947,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -39649,10 +43001,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -39677,13 +43031,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -39700,7 +43054,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -39736,8 +43107,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -39873,10 +43249,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -39901,13 +43279,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -39924,7 +43302,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -39960,8 +43355,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -40250,66 +43650,87 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item @JsonProperty("matrix_with_display_name_config") @ExcludeMissing - fun _matrixWithDisplayNameConfig() = matrixWithDisplayNameConfig + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -40355,32 +43776,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var matrixWithDisplayNameConfig: JsonField = - JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40416,8 +43834,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -40434,8 +43855,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -40447,8 +43874,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -40458,27 +43888,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -40496,11 +43954,17 @@ private constructor( matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -40520,11 +43984,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -40538,7 +44008,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -40569,29 +44046,41 @@ private constructor( fun build(): MatrixWithDisplayNamePrice = MatrixWithDisplayNamePrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - matrixWithDisplayNameConfig, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(matrixWithDisplayNameConfig) { + "`matrixWithDisplayNameConfig` is required but was not set" + }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -40609,7 +44098,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -40633,7 +44122,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40668,7 +44157,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -40707,9 +44200,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -40734,8 +44229,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40781,8 +44276,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -40961,9 +44456,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -40988,8 +44485,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -41034,8 +44531,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -41076,9 +44575,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -41103,8 +44604,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -41151,8 +44652,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -41250,9 +44751,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -41277,8 +44778,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -41320,8 +44821,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -41456,10 +44957,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -41484,13 +44987,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -41507,7 +45010,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -41543,8 +45063,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -41680,10 +45205,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -41708,13 +45235,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -41731,7 +45258,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -41767,8 +45311,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -42056,66 +45605,86 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration @JsonProperty("bulk_with_proration_config") @ExcludeMissing - fun _bulkWithProrationConfig() = bulkWithProrationConfig + fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -42161,32 +45730,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var bulkWithProrationConfig: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42221,8 +45787,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -42246,8 +45815,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -42259,8 +45834,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -42270,27 +45848,55 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -42300,11 +45906,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -42324,11 +45936,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -42342,7 +45960,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -42373,29 +45998,41 @@ private constructor( fun build(): BulkWithProrationPrice = BulkWithProrationPrice( - id, - billableMetric, - billingCycleConfiguration, - bulkWithProrationConfig, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(bulkWithProrationConfig) { + "`bulkWithProrationConfig` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -42413,7 +46050,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -42437,7 +46074,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42472,7 +46109,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -42511,9 +46152,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -42538,8 +46181,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42585,8 +46228,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -42846,9 +46489,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -42873,8 +46518,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42919,8 +46564,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -42961,9 +46608,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -42988,8 +46637,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -43036,8 +46685,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -43135,9 +46784,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -43162,8 +46811,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -43205,8 +46854,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -43259,10 +46908,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -43287,13 +46938,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -43310,7 +46961,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -43346,8 +47014,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -43483,10 +47156,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -43511,13 +47186,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -43534,7 +47209,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -43570,8 +47262,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -43860,66 +47557,87 @@ private constructor( fun priceType(): PriceType = priceType.getRequired("price_type") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric @JsonProperty("billing_cycle_configuration") @ExcludeMissing - fun _billingCycleConfiguration() = billingCycleConfiguration + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration - @JsonProperty("cadence") @ExcludeMissing fun _cadence() = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - @JsonProperty("conversion_rate") @ExcludeMissing fun _conversionRate() = conversionRate + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt @JsonProperty("credit_allocation") @ExcludeMissing - fun _creditAllocation() = creditAllocation + fun _creditAllocation(): JsonField = creditAllocation - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - @JsonProperty("discount") @ExcludeMissing fun _discount() = discount + @JsonProperty("discount") @ExcludeMissing fun _discount(): JsonField = discount - @JsonProperty("external_price_id") @ExcludeMissing fun _externalPriceId() = externalPriceId + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId @JsonProperty("fixed_price_quantity") @ExcludeMissing - fun _fixedPriceQuantity() = fixedPriceQuantity + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity @JsonProperty("grouped_tiered_package_config") @ExcludeMissing - fun _groupedTieredPackageConfig() = groupedTieredPackageConfig + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig @JsonProperty("invoicing_cycle_configuration") @ExcludeMissing - fun _invoicingCycleConfiguration() = invoicingCycleConfiguration + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration - @JsonProperty("item") @ExcludeMissing fun _item() = item + @JsonProperty("item") @ExcludeMissing fun _item(): JsonField = item - @JsonProperty("maximum") @ExcludeMissing fun _maximum() = maximum + @JsonProperty("maximum") @ExcludeMissing fun _maximum(): JsonField = maximum - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * User specified key-value pairs for the resource. If not present, this defaults to an * empty dictionary. Individual keys can be removed by setting the value to `null`, and the * entire metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata - @JsonProperty("minimum") @ExcludeMissing fun _minimum() = minimum + @JsonProperty("minimum") @ExcludeMissing fun _minimum(): JsonField = minimum - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount - @JsonProperty("model_type") @ExcludeMissing fun _modelType() = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("plan_phase_order") @ExcludeMissing fun _planPhaseOrder() = planPhaseOrder + @JsonProperty("plan_phase_order") + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder - @JsonProperty("price_type") @ExcludeMissing fun _priceType() = priceType + @JsonProperty("price_type") + @ExcludeMissing + fun _priceType(): JsonField = priceType @JsonAnyGetter @ExcludeMissing @@ -43965,32 +47683,29 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billableMetric: JsonField = JsonMissing.of() - private var billingCycleConfiguration: JsonField = - JsonMissing.of() - private var cadence: JsonField = JsonMissing.of() - private var conversionRate: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var creditAllocation: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() - private var discount: JsonField = JsonMissing.of() - private var externalPriceId: JsonField = JsonMissing.of() - private var fixedPriceQuantity: JsonField = JsonMissing.of() - private var groupedTieredPackageConfig: JsonField = - JsonMissing.of() - private var invoicingCycleConfiguration: JsonField = - JsonMissing.of() - private var item: JsonField = JsonMissing.of() - private var maximum: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimum: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var modelType: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var priceType: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billableMetric: JsonField? = null + private var billingCycleConfiguration: JsonField? = null + private var cadence: JsonField? = null + private var conversionRate: JsonField? = null + private var createdAt: JsonField? = null + private var creditAllocation: JsonField? = null + private var currency: JsonField? = null + private var discount: JsonField? = null + private var externalPriceId: JsonField? = null + private var fixedPriceQuantity: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = null + private var invoicingCycleConfiguration: JsonField? = null + private var item: JsonField? = null + private var maximum: JsonField? = null + private var maximumAmount: JsonField? = null + private var metadata: JsonField? = null + private var minimum: JsonField? = null + private var minimumAmount: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var priceType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44025,8 +47740,11 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } - fun billableMetric(billableMetric: BillableMetric) = - billableMetric(JsonField.of(billableMetric)) + fun billableMetric(billableMetric: BillableMetric?) = + billableMetric(JsonField.ofNullable(billableMetric)) + + fun billableMetric(billableMetric: Optional) = + billableMetric(billableMetric.orElse(null)) fun billableMetric(billableMetric: JsonField) = apply { this.billableMetric = billableMetric @@ -44043,8 +47761,14 @@ private constructor( fun cadence(cadence: JsonField) = apply { this.cadence = cadence } - fun conversionRate(conversionRate: Double) = - conversionRate(JsonField.of(conversionRate)) + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) + + fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) fun conversionRate(conversionRate: JsonField) = apply { this.conversionRate = conversionRate @@ -44056,8 +47780,11 @@ private constructor( this.createdAt = createdAt } - fun creditAllocation(creditAllocation: CreditAllocation) = - creditAllocation(JsonField.of(creditAllocation)) + fun creditAllocation(creditAllocation: CreditAllocation?) = + creditAllocation(JsonField.ofNullable(creditAllocation)) + + fun creditAllocation(creditAllocation: Optional) = + creditAllocation(creditAllocation.orElse(null)) fun creditAllocation(creditAllocation: JsonField) = apply { this.creditAllocation = creditAllocation @@ -44067,19 +47794,43 @@ private constructor( fun currency(currency: JsonField) = apply { this.currency = currency } - fun discount(discount: Discount) = discount(JsonField.of(discount)) + fun discount(discount: Discount?) = discount(JsonField.ofNullable(discount)) + + fun discount(discount: Optional) = discount(discount.orElse(null)) fun discount(discount: JsonField) = apply { this.discount = discount } - fun externalPriceId(externalPriceId: String) = - externalPriceId(JsonField.of(externalPriceId)) + fun discount(percentageDiscount: PercentageDiscount) = + discount(Discount.ofPercentageDiscount(percentageDiscount)) + + fun discount(trialDiscount: TrialDiscount) = + discount(Discount.ofTrialDiscount(trialDiscount)) + + fun discount(usageDiscount: Discount.UsageDiscount) = + discount(Discount.ofUsageDiscount(usageDiscount)) + + fun discount(amountDiscount: AmountDiscount) = + discount(Discount.ofAmountDiscount(amountDiscount)) + + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + + fun externalPriceId(externalPriceId: Optional) = + externalPriceId(externalPriceId.orElse(null)) fun externalPriceId(externalPriceId: JsonField) = apply { this.externalPriceId = externalPriceId } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + fun fixedPriceQuantity(fixedPriceQuantity: Double) = - fixedPriceQuantity(JsonField.of(fixedPriceQuantity)) + fixedPriceQuantity(fixedPriceQuantity as Double?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun fixedPriceQuantity(fixedPriceQuantity: Optional) = + fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { this.fixedPriceQuantity = fixedPriceQuantity @@ -44093,8 +47844,12 @@ private constructor( ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } fun invoicingCycleConfiguration( - invoicingCycleConfiguration: InvoicingCycleConfiguration - ) = invoicingCycleConfiguration(JsonField.of(invoicingCycleConfiguration)) + invoicingCycleConfiguration: InvoicingCycleConfiguration? + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) + + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: Optional + ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) fun invoicingCycleConfiguration( invoicingCycleConfiguration: JsonField @@ -44104,11 +47859,17 @@ private constructor( fun item(item: JsonField) = apply { this.item = item } - fun maximum(maximum: Maximum) = maximum(JsonField.of(maximum)) + fun maximum(maximum: Maximum?) = maximum(JsonField.ofNullable(maximum)) + + fun maximum(maximum: Optional) = maximum(maximum.orElse(null)) fun maximum(maximum: JsonField) = apply { this.maximum = maximum } - fun maximumAmount(maximumAmount: String) = maximumAmount(JsonField.of(maximumAmount)) + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) + + fun maximumAmount(maximumAmount: Optional) = + maximumAmount(maximumAmount.orElse(null)) fun maximumAmount(maximumAmount: JsonField) = apply { this.maximumAmount = maximumAmount @@ -44128,11 +47889,17 @@ private constructor( */ fun metadata(metadata: JsonField) = apply { this.metadata = metadata } - fun minimum(minimum: Minimum) = minimum(JsonField.of(minimum)) + fun minimum(minimum: Minimum?) = minimum(JsonField.ofNullable(minimum)) + + fun minimum(minimum: Optional) = minimum(minimum.orElse(null)) fun minimum(minimum: JsonField) = apply { this.minimum = minimum } - fun minimumAmount(minimumAmount: String) = minimumAmount(JsonField.of(minimumAmount)) + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) + + fun minimumAmount(minimumAmount: Optional) = + minimumAmount(minimumAmount.orElse(null)) fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount @@ -44146,7 +47913,14 @@ private constructor( fun name(name: JsonField) = apply { this.name = name } - fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(JsonField.of(planPhaseOrder)) + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + + fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) + + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) fun planPhaseOrder(planPhaseOrder: JsonField) = apply { this.planPhaseOrder = planPhaseOrder @@ -44177,29 +47951,41 @@ private constructor( fun build(): GroupedTieredPackagePrice = GroupedTieredPackagePrice( - id, - billableMetric, - billingCycleConfiguration, - cadence, - conversionRate, - createdAt, - creditAllocation, - currency, - discount, - externalPriceId, - fixedPriceQuantity, - groupedTieredPackageConfig, - invoicingCycleConfiguration, - item, - maximum, - maximumAmount, - metadata, - minimum, - minimumAmount, - modelType, - name, - planPhaseOrder, - priceType, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billableMetric) { "`billableMetric` is required but was not set" }, + checkNotNull(billingCycleConfiguration) { + "`billingCycleConfiguration` is required but was not set" + }, + checkNotNull(cadence) { "`cadence` is required but was not set" }, + checkNotNull(conversionRate) { "`conversionRate` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(creditAllocation) { + "`creditAllocation` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, + checkNotNull(discount) { "`discount` is required but was not set" }, + checkNotNull(externalPriceId) { + "`externalPriceId` is required but was not set" + }, + checkNotNull(fixedPriceQuantity) { + "`fixedPriceQuantity` is required but was not set" + }, + checkNotNull(groupedTieredPackageConfig) { + "`groupedTieredPackageConfig` is required but was not set" + }, + checkNotNull(invoicingCycleConfiguration) { + "`invoicingCycleConfiguration` is required but was not set" + }, + checkNotNull(item) { "`item` is required but was not set" }, + checkNotNull(maximum) { "`maximum` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimum) { "`minimum` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(modelType) { "`modelType` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, + checkNotNull(planPhaseOrder) { "`planPhaseOrder` is required but was not set" }, + checkNotNull(priceType) { "`priceType` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -44217,7 +48003,7 @@ private constructor( fun id(): String = id.getRequired("id") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonAnyGetter @ExcludeMissing @@ -44241,7 +48027,7 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() + private var id: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44276,7 +48062,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): BillableMetric = BillableMetric(id, additionalProperties.toImmutable()) + fun build(): BillableMetric = + BillableMetric( + checkNotNull(id) { "`id` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { @@ -44315,9 +48105,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -44342,8 +48134,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44389,8 +48181,8 @@ private constructor( fun build(): BillingCycleConfiguration = BillingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -44569,9 +48361,11 @@ private constructor( fun currency(): String = currency.getRequired("currency") - @JsonProperty("allows_rollover") @ExcludeMissing fun _allowsRollover() = allowsRollover + @JsonProperty("allows_rollover") + @ExcludeMissing + fun _allowsRollover(): JsonField = allowsRollover - @JsonProperty("currency") @ExcludeMissing fun _currency() = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonAnyGetter @ExcludeMissing @@ -44596,8 +48390,8 @@ private constructor( class Builder { - private var allowsRollover: JsonField = JsonMissing.of() - private var currency: JsonField = JsonMissing.of() + private var allowsRollover: JsonField? = null + private var currency: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44642,8 +48436,10 @@ private constructor( fun build(): CreditAllocation = CreditAllocation( - allowsRollover, - currency, + checkNotNull(allowsRollover) { + "`allowsRollover` is required but was not set" + }, + checkNotNull(currency) { "`currency` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -44765,9 +48561,11 @@ private constructor( fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") - @JsonProperty("duration") @ExcludeMissing fun _duration() = duration + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration - @JsonProperty("duration_unit") @ExcludeMissing fun _durationUnit() = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing @@ -44792,8 +48590,8 @@ private constructor( class Builder { - private var duration: JsonField = JsonMissing.of() - private var durationUnit: JsonField = JsonMissing.of() + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44840,8 +48638,8 @@ private constructor( fun build(): InvoicingCycleConfiguration = InvoicingCycleConfiguration( - duration, - durationUnit, + checkNotNull(duration) { "`duration` is required but was not set" }, + checkNotNull(durationUnit) { "`durationUnit` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -44939,9 +48737,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -44966,8 +48764,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -45009,8 +48807,8 @@ private constructor( fun build(): Item = Item( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -45063,10 +48861,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Maximum amount applied */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount @JsonAnyGetter @ExcludeMissing @@ -45091,13 +48891,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximum: Maximum) = apply { - appliesToPriceIds = maximum.appliesToPriceIds + appliesToPriceIds = maximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = maximum.maximumAmount additionalProperties = maximum.additionalProperties.toMutableMap() } @@ -45114,7 +48914,24 @@ private constructor( * maximums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this maximum amount applies to. For plan/plan phase + * maximums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Maximum amount applied */ @@ -45150,8 +48967,13 @@ private constructor( fun build(): Maximum = Maximum( - appliesToPriceIds.map { it.toImmutable() }, - maximumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -45287,10 +49109,12 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** Minimum amount applied */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount @JsonAnyGetter @ExcludeMissing @@ -45315,13 +49139,13 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var minimumAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimum: Minimum) = apply { - appliesToPriceIds = minimum.appliesToPriceIds + appliesToPriceIds = minimum.appliesToPriceIds.map { it.toMutableList() } minimumAmount = minimum.minimumAmount additionalProperties = minimum.additionalProperties.toMutableMap() } @@ -45338,7 +49162,24 @@ private constructor( * minimums, this can be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this minimum amount applies to. For plan/plan phase + * minimums, this can be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** Minimum amount applied */ @@ -45374,8 +49215,13 @@ private constructor( fun build(): Minimum = Minimum( - appliesToPriceIds.map { it.toImmutable() }, - minimumAmount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt index 12087044..1b63c225 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceCreateParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,17 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint is used to create a [price](../reference/price). A price created using this + * endpoint is always an add-on, meaning that it’s not associated with a specific plan and can + * instead be individually added to subscriptions, including subscriptions on different plans. + * + * An `external_price_id` can be optionally specified as an alias to allow ergonomic interaction + * with prices in the Orb API. + * + * See the [Price resource](../reference/price) for the specification of different price model + * configurations possible in this endpoint. + */ class PriceCreateParams constructor( private val body: PriceCreateBody, @@ -1343,94 +1355,224 @@ constructor( class NewFloatingUnitPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingUnitPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1440,21 +1582,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1478,27 +1622,44 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -1506,13 +1667,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -1529,13 +1696,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -1544,10 +1717,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -1557,21 +1736,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -1586,22 +1773,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -1611,12 +1809,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -1625,6 +1831,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1801,18 +2014,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1822,7 +2051,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1832,7 +2061,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -1886,22 +2120,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1911,8 +2167,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1924,10 +2180,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -2044,22 +2307,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2069,8 +2354,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2083,10 +2368,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -2212,6 +2504,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2292,132 +2592,264 @@ constructor( class NewFloatingPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") /** The id of the billable metric for the price. Only needed if the price is usage-based. */ - @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) /** For custom cadence: specifies the duration of the billing period in days or months. */ - @JsonProperty("billing_cycle_configuration") fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) /** The per unit conversion rate of the price currency to the invoicing currency. */ - @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) /** An alias for the price. */ - @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) /** If the Price represents a fixed cost, this represents the quantity of units applied. */ - @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) /** The property used to group this price on an invoice */ - @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ - @JsonProperty("invoicing_cycle_configuration") fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - @JsonAnyGetter - @ExcludeMissing - fun _additionalProperties(): Map = additionalProperties + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence - fun toBuilder() = Builder().from(this) + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency - companion object { + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JvmStatic fun builder() = Builder() - } + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType - class Builder { + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var additionalProperties: MutableMap = mutableMapOf() + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig - @JvmSynthetic - internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { - cadence = newFloatingPackagePrice.cadence - currency = newFloatingPackagePrice.currency - itemId = newFloatingPackagePrice.itemId - modelType = newFloatingPackagePrice.modelType - name = newFloatingPackagePrice.name - packageConfig = newFloatingPackagePrice.packageConfig - billableMetricId = newFloatingPackagePrice.billableMetricId - billedInAdvance = newFloatingPackagePrice.billedInAdvance - billingCycleConfiguration = newFloatingPackagePrice.billingCycleConfiguration - conversionRate = newFloatingPackagePrice.conversionRate + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + @JsonProperty("billable_metric_id") + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + @JsonProperty("billed_in_advance") + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + @JsonProperty("conversion_rate") + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate + + /** An alias for the price. */ + @JsonProperty("external_price_id") + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity + + /** The property used to group this price on an invoice */ + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata + + @JsonAnyGetter + @ExcludeMissing + fun _additionalProperties(): Map = additionalProperties + + private var validated: Boolean = false + + fun validate(): NewFloatingPackagePrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + + fun toBuilder() = Builder().from(this) + + companion object { + + @JvmStatic fun builder() = Builder() + } + + class Builder { + + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var additionalProperties: MutableMap = mutableMapOf() + + @JvmSynthetic + internal fun from(newFloatingPackagePrice: NewFloatingPackagePrice) = apply { + cadence = newFloatingPackagePrice.cadence + currency = newFloatingPackagePrice.currency + itemId = newFloatingPackagePrice.itemId + modelType = newFloatingPackagePrice.modelType + name = newFloatingPackagePrice.name + packageConfig = newFloatingPackagePrice.packageConfig + billableMetricId = newFloatingPackagePrice.billableMetricId + billedInAdvance = newFloatingPackagePrice.billedInAdvance + billingCycleConfiguration = newFloatingPackagePrice.billingCycleConfiguration + conversionRate = newFloatingPackagePrice.conversionRate externalPriceId = newFloatingPackagePrice.externalPriceId fixedPriceQuantity = newFloatingPackagePrice.fixedPriceQuantity invoiceGroupingKey = newFloatingPackagePrice.invoiceGroupingKey @@ -2427,29 +2859,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -2457,13 +2905,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -2480,13 +2934,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -2495,10 +2955,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -2508,21 +2974,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -2537,22 +3011,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -2562,12 +3047,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -2576,6 +3069,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -2752,25 +3252,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would divide + * usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would divide * usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2780,8 +3307,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2792,7 +3319,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -2800,7 +3331,15 @@ constructor( * An integer amount to represent package size. For example, 1000 here would divide * usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { this.packageSize = packageSize } + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would divide + * usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { + this.packageSize = packageSize + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2857,22 +3396,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2882,8 +3443,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -2895,10 +3456,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -3015,22 +3583,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3040,8 +3630,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3054,10 +3644,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -3183,6 +3780,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3263,94 +3868,224 @@ constructor( class NewFloatingMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3360,21 +4095,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3398,29 +4135,44 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfig) = matrixConfig(JsonField.of(matrixConfig)) - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -3428,13 +4180,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -3451,13 +4209,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -3466,10 +4230,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -3479,21 +4249,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -3508,22 +4286,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -3533,12 +4322,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -3547,6 +4344,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3672,26 +4476,58 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("default_unit_amount") fun defaultUnitAmount(): String = defaultUnitAmount + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + fun dimensions(): List = dimensions.getRequired("dimensions") /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") fun matrixValues(): List = matrixValues + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount + + /** One or two event property values to evaluate matrix groups by */ + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions + + /** Matrix values for specified matrix grouping keys */ + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3701,44 +4537,75 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } /** * Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -3769,9 +4636,9 @@ constructor( "`defaultUnitAmount` is required but was not set" }, checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -3780,27 +4647,55 @@ constructor( class MatrixValue @JsonCreator private constructor( - @JsonProperty("dimension_values") private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("dimension_values") + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an + * instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For example, * ["region", "tier"] could be used to filter cloud usage by a cloud region and an * instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3810,13 +4705,13 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() } @@ -3826,8 +4721,16 @@ constructor( * ["region", "tier"] could be used to filter cloud usage by a cloud region and * an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and + * an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -3837,11 +4740,24 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { add(dimensionValue) } + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -3870,7 +4786,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, additionalProperties.toImmutable(), ) @@ -3968,22 +4884,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3993,8 +4931,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4006,10 +4944,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -4126,22 +5071,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4151,8 +5118,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4165,10 +5132,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -4294,6 +5268,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4374,96 +5356,227 @@ constructor( class NewFloatingMatrixWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), @JsonProperty("matrix_with_allocation_config") - private val matrixWithAllocationConfig: MatrixWithAllocationConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @JsonProperty("matrix_with_allocation_config") - fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = matrixWithAllocationConfig + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = + matrixWithAllocationConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixWithAllocationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + matrixWithAllocationConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4473,21 +5586,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var matrixWithAllocationConfig: MatrixWithAllocationConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithAllocationConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4517,30 +5632,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } fun matrixWithAllocationConfig(matrixWithAllocationConfig: MatrixWithAllocationConfig) = - apply { - this.matrixWithAllocationConfig = matrixWithAllocationConfig - } + matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) + + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: JsonField + ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -4548,13 +5678,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -4571,13 +5707,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -4586,10 +5728,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -4599,21 +5747,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -4628,22 +5784,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -4653,12 +5820,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -4667,6 +5842,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4794,30 +5976,70 @@ constructor( class MatrixWithAllocationConfig @JsonCreator private constructor( - @JsonProperty("allocation") private val allocation: Double, - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("allocation") + @ExcludeMissing + private val allocation: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") fun allocation(): Double = allocation + fun allocation(): Double = allocation.getRequired("allocation") + + /** Default per unit rate for any usage not bucketed into a specified matrix_value */ + fun defaultUnitAmount(): String = defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = matrixValues.getRequired("matrix_values") + + /** Allocation to be used to calculate the price */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation /** Default per unit rate for any usage not bucketed into a specified matrix_value */ - @JsonProperty("default_unit_amount") fun defaultUnitAmount(): String = defaultUnitAmount + @JsonProperty("default_unit_amount") + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ - @JsonProperty("matrix_values") fun matrixValues(): List = matrixValues + @JsonProperty("matrix_values") + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixWithAllocationConfig = apply { + if (!validated) { + allocation() + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4827,50 +6049,87 @@ constructor( class Builder { - private var allocation: Double? = null - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var allocation: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixWithAllocationConfig: MatrixWithAllocationConfig) = apply { allocation = matrixWithAllocationConfig.allocation defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - dimensions = matrixWithAllocationConfig.dimensions.toMutableList() - matrixValues = matrixWithAllocationConfig.matrixValues.toMutableList() + dimensions = matrixWithAllocationConfig.dimensions.map { it.toMutableList() } + matrixValues = + matrixWithAllocationConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixWithAllocationConfig.additionalProperties.toMutableMap() } /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = apply { this.allocation = allocation } + fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) + + /** Allocation to be used to calculate the price */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } + + /** + * Default per unit rate for any usage not bucketed into a specified matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) /** * Default per unit rate for any usage not bucketed into a specified matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { - matrixValues = (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + matrixValues = + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -4902,9 +6161,9 @@ constructor( "`defaultUnitAmount` is required but was not set" }, checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -4913,27 +6172,55 @@ constructor( class MatrixValue @JsonCreator private constructor( - @JsonProperty("dimension_values") private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("dimension_values") + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and an + * instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For example, * ["region", "tier"] could be used to filter cloud usage by a cloud region and an * instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4943,13 +6230,13 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() } @@ -4959,8 +6246,16 @@ constructor( * ["region", "tier"] could be used to filter cloud usage by a cloud region and * an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For example, + * ["region", "tier"] could be used to filter cloud usage by a cloud region and + * an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -4970,11 +6265,24 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { add(dimensionValue) } + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) + } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -5003,7 +6311,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, additionalProperties.toImmutable(), ) @@ -5101,22 +6409,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5126,8 +6456,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5139,10 +6469,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5259,22 +6596,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5284,8 +6643,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5298,10 +6657,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5427,6 +6793,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5482,119 +6856,249 @@ constructor( override fun hashCode(): Int = hashCode - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingMatrixWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - return /* spotless:off */ other is NewFloatingMatrixWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && matrixWithAllocationConfig == other.matrixWithAllocationConfig && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, matrixWithAllocationConfig, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingMatrixWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, matrixWithAllocationConfig=$matrixWithAllocationConfig, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5604,21 +7108,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5642,29 +7148,44 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: TieredConfig) = tieredConfig(JsonField.of(tieredConfig)) + + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -5672,13 +7193,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -5695,13 +7222,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -5710,10 +7243,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -5723,21 +7262,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -5752,22 +7299,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -5777,12 +7335,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -5791,6 +7357,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5967,18 +7540,32 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5988,21 +7575,35 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Tiers for rating based on total usage quantities into the specified tier */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -6029,7 +7630,8 @@ constructor( fun build(): TieredConfig = TieredConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -6038,27 +7640,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") + + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6068,9 +7702,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6082,13 +7716,23 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } /** Exclusive tier ending value. If null, this is treated as the last tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = lastUnit(JsonField.ofNullable(lastUnit)) /** Exclusive tier ending value. If null, this is treated as the last tier */ fun lastUnit(lastUnit: Double) = lastUnit(lastUnit as Double?) @@ -6098,6 +7742,9 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** Exclusive tier ending value. If null, this is treated as the last tier */ + fun lastUnit(lastUnit: JsonField) = apply { this.lastUnit = lastUnit } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6170,22 +7817,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6195,8 +7864,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6208,10 +7877,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6328,22 +8004,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6353,8 +8051,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6367,10 +8065,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6496,6 +8201,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6576,94 +8289,224 @@ constructor( class NewFloatingTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig.getRequired("tiered_bps_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tiered_bps_config") fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @JsonProperty("tiered_bps_config") + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredBpsPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6673,21 +8516,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6711,29 +8556,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -6741,13 +8602,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -6764,13 +8631,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -6779,10 +8652,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -6792,21 +8671,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -6821,22 +8708,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -6846,12 +8744,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -6860,6 +8766,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7038,7 +8951,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -7046,12 +8961,26 @@ constructor( /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified tiers + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7061,12 +8990,12 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -7074,14 +9003,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified * tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified + * tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into specified * tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -7108,7 +9054,8 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -7117,32 +9064,70 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Inclusive tier starting value */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7152,10 +9137,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7168,31 +9153,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7268,22 +9268,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7293,8 +9315,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7306,10 +9328,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7426,22 +9455,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7451,8 +9502,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7465,10 +9516,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7594,6 +9652,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7643,125 +9709,255 @@ constructor( return /* spotless:off */ other is Metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(additionalProperties) } - /* spotless:on */ + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = "Metadata{additionalProperties=$additionalProperties}" + } + + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) - override fun toString() = "Metadata{additionalProperties=$additionalProperties}" - } + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7771,21 +9967,23 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7808,28 +10006,43 @@ constructor( additionalProperties = newFloatingBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { this.bpsConfig = bpsConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -7837,13 +10050,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -7860,13 +10079,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -7875,10 +10100,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -7888,21 +10119,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -7917,22 +10156,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -7942,12 +10192,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -7956,6 +10214,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8000,23 +10265,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8026,8 +10313,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8038,17 +10325,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8234,22 +10528,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8259,8 +10575,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8272,10 +10588,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8392,22 +10715,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8417,8 +10762,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8431,10 +10776,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8560,6 +10912,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8636,98 +10996,228 @@ constructor( "NewFloatingBpsPrice{bpsConfig=$bpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - @NoAutoDetect - class NewFloatingBulkBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @NoAutoDetect + class NewFloatingBulkBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8737,21 +11227,23 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8774,30 +11266,46 @@ constructor( additionalProperties = newFloatingBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -8805,13 +11313,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -8828,13 +11342,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -8843,10 +11363,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -8856,21 +11382,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -8885,22 +11419,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -8910,12 +11455,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -8924,6 +11477,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8968,7 +11528,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -8977,12 +11539,27 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier * based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier + * based on total volume + */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8992,12 +11569,12 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -9005,14 +11582,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier * based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier + * based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a single tier * based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -9039,7 +11633,8 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -9048,28 +11643,58 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9079,9 +11704,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9093,26 +11718,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9317,22 +11953,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9342,8 +12000,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9355,10 +12013,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9475,22 +12140,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9500,8 +12187,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9514,10 +12201,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9643,6 +12337,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9706,111 +12408,241 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingBulkBpsPrice && bulkBpsConfig == other.bulkBpsConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBulkPrice + @JsonCreator + private constructor( + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkBpsConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingBulkBpsPrice{bulkBpsConfig=$bulkBpsConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingBulkPrice - @JsonCreator - private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9820,21 +12652,23 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9857,28 +12691,45 @@ constructor( additionalProperties = newFloatingBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -9886,13 +12737,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -9909,13 +12766,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -9924,10 +12787,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -9937,21 +12806,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -9966,22 +12843,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -9991,12 +12879,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -10005,6 +12901,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10049,18 +12952,32 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") @ExcludeMissing fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10070,21 +12987,35 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -10111,7 +13042,8 @@ constructor( fun build(): BulkConfig = BulkConfig( - checkNotNull(tiers) { "`tiers` is required but was not set" }.toImmutable(), + checkNotNull(tiers) { "`tiers` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -10120,23 +13052,47 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10146,8 +13102,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10158,13 +13114,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) - /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount } + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) + /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = maximumUnits(maximumUnits as Double?) @@ -10173,6 +13133,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10376,22 +13341,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10401,8 +13388,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10414,10 +13401,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10534,22 +13528,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10559,8 +13575,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10573,10 +13589,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10702,6 +13725,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10782,96 +13813,227 @@ constructor( class NewFloatingThresholdTotalAmountPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("threshold_total_amount_config") - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = thresholdTotalAmountConfig + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = + thresholdTotalAmountConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10881,21 +14043,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10925,30 +14089,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig(thresholdTotalAmountConfig: ThresholdTotalAmountConfig) = - apply { - this.thresholdTotalAmountConfig = thresholdTotalAmountConfig - } + thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField + ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -10956,13 +14135,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -10979,13 +14164,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -10994,10 +14185,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -11007,21 +14204,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -11036,22 +14241,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -11061,12 +14277,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -11075,6 +14299,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -11261,6 +14492,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11327,22 +14566,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11352,8 +14613,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11365,10 +14626,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11485,22 +14753,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11510,8 +14800,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11524,10 +14814,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11653,6 +14950,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11733,95 +15038,225 @@ constructor( class NewFloatingTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_package_config") private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPackagePrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11831,21 +15266,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11873,29 +15310,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = apply { this.tieredPackageConfig = tieredPackageConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -11903,13 +15356,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -11926,13 +15385,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -11941,10 +15406,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -11954,21 +15425,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -11983,22 +15462,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -12008,12 +15498,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -12022,6 +15520,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -12208,6 +15713,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12273,22 +15786,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12298,8 +15833,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12311,10 +15846,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12431,22 +15973,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12456,8 +16020,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12470,10 +16034,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12599,6 +16170,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12679,95 +16258,225 @@ constructor( class NewFloatingGroupedTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("grouped_tiered_config") private val groupedTieredConfig: GroupedTieredConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + private val groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonProperty("grouped_tiered_config") - fun groupedTieredConfig(): GroupedTieredConfig = groupedTieredConfig + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedTieredPrice = apply { + if (!validated) { + cadence() + currency() + groupedTieredConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12777,21 +16486,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedTieredConfig: GroupedTieredConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12819,29 +16530,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = apply { + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + fun groupedTieredConfig(groupedTieredConfig: JsonField) = apply { this.groupedTieredConfig = groupedTieredConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -12849,13 +16576,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -12872,13 +16605,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -12887,10 +16626,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -12900,21 +16645,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -12929,22 +16682,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -12954,12 +16718,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -12968,6 +16740,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13103,6 +16882,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13219,22 +17006,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13244,8 +17053,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13257,10 +17066,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13377,22 +17193,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13402,8 +17240,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13416,10 +17254,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13545,6 +17390,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13625,96 +17478,225 @@ constructor( class NewFloatingTieredWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = tieredWithMinimumConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13724,21 +17706,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13767,29 +17751,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -13797,13 +17797,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -13820,13 +17826,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -13835,10 +17847,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -13848,21 +17866,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -13877,22 +17903,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -13902,12 +17939,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -13916,6 +17961,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -14102,6 +18154,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14168,22 +18228,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14193,8 +18275,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14206,10 +18288,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14326,22 +18415,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14351,8 +18462,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14365,10 +18476,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14494,6 +18612,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14574,96 +18700,227 @@ constructor( class NewFloatingPackageWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("package_with_allocation_config") - fun packageWithAllocationConfig(): PackageWithAllocationConfig = packageWithAllocationConfig + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = + packageWithAllocationConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14673,21 +18930,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14717,29 +18976,46 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -14747,13 +19023,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -14770,13 +19052,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -14785,10 +19073,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -14798,21 +19092,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -14827,22 +19129,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -14852,12 +19165,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -14866,6 +19187,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15052,6 +19380,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15119,22 +19455,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15144,8 +19502,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15157,10 +19515,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15277,22 +19642,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15302,8 +19689,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15316,10 +19703,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15445,6 +19839,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15525,97 +19927,227 @@ constructor( class NewFloatingTieredPackageWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_with_minimum_config") - private val tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredPackageWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_package_with_minimum_config") fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = tieredPackageWithMinimumConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15625,21 +20157,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15669,29 +20204,46 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredPackageWithMinimumConfig( tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -15699,13 +20251,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -15722,13 +20280,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -15737,10 +20301,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -15750,21 +20320,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. - */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -15779,22 +20357,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -15804,12 +20393,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -15818,6 +20415,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16004,6 +20608,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16071,22 +20683,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16096,8 +20730,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16109,10 +20743,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16229,22 +20870,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16254,8 +20917,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16268,10 +20931,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16397,6 +21067,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16477,96 +21155,225 @@ constructor( class NewFloatingUnitWithPercentPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithPercentConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = unitWithPercentConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingUnitWithPercentPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16576,21 +21383,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16618,29 +21427,46 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig(unitWithPercentConfig: JsonField) = + apply { + this.unitWithPercentConfig = unitWithPercentConfig + } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -16648,13 +21474,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -16671,13 +21503,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -16686,10 +21524,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -16699,21 +21543,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -16728,22 +21580,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -16753,12 +21616,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -16767,6 +21638,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16953,6 +21831,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17018,22 +21904,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17043,8 +21951,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17056,10 +21964,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17176,22 +22091,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17201,8 +22138,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17215,10 +22152,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17344,6 +22288,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17424,96 +22376,227 @@ constructor( class NewFloatingTieredWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_proration_config") - fun tieredWithProrationConfig(): TieredWithProrationConfig = tieredWithProrationConfig + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = + tieredWithProrationConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredWithProrationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17523,21 +22606,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17567,30 +22652,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig(tieredWithProrationConfig: TieredWithProrationConfig) = - apply { - this.tieredWithProrationConfig = tieredWithProrationConfig - } + tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField + ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -17598,13 +22698,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -17621,13 +22727,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -17636,10 +22748,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -17649,21 +22767,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -17678,22 +22804,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -17703,12 +22840,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -17717,6 +22862,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -17903,6 +23055,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17969,22 +23129,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17994,8 +23176,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18007,10 +23189,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18127,22 +23316,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18152,8 +23363,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18166,10 +23377,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18295,6 +23513,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18375,96 +23601,225 @@ constructor( class NewFloatingUnitWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = unitWithProrationConfig /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingUnitWithProrationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18474,21 +23829,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18517,29 +23874,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -18547,13 +23920,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -18570,13 +23949,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -18585,10 +23970,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -18598,21 +23989,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -18627,22 +24026,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -18652,12 +24062,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -18666,6 +24084,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -18852,6 +24277,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18918,22 +24351,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18943,8 +24398,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18956,10 +24411,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19076,22 +24538,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19101,8 +24585,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19115,10 +24599,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19244,6 +24735,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19324,96 +24823,225 @@ constructor( class NewFloatingGroupedAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedAllocationConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedAllocationPrice = apply { + if (!validated) { + cadence() + currency() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19423,21 +25051,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19466,29 +25096,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) - fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -19496,13 +25142,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -19519,13 +25171,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -19534,10 +25192,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -19547,21 +25211,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -19576,22 +25248,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -19601,12 +25284,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -19615,6 +25306,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19750,6 +25448,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19867,22 +25573,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19892,8 +25620,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19905,10 +25633,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20025,22 +25760,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20050,8 +25807,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20064,10 +25821,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20193,6 +25957,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20273,97 +26045,227 @@ constructor( class NewFloatingGroupedWithProratedMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithProratedMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") - @JsonProperty("grouped_with_prorated_minimum_config") fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired("grouped_with_prorated_minimum_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): JsonField = groupedWithProratedMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + currency() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20373,21 +26275,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithProratedMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20418,29 +26324,46 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = groupedWithProratedMinimumConfig(JsonField.of(groupedWithProratedMinimumConfig)) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -20448,13 +26371,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -20471,13 +26400,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -20486,10 +26421,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -20499,21 +26440,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -20528,22 +26477,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -20553,12 +26513,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -20567,6 +26535,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -20702,6 +26677,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20821,22 +26804,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20846,8 +26851,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20859,10 +26864,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20979,22 +26991,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21004,8 +27038,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21018,10 +27052,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21147,6 +27188,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21227,97 +27276,227 @@ constructor( class NewFloatingGroupedWithMeteredMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_metered_minimum_config") - private val groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") - @JsonProperty("grouped_with_metered_minimum_config") fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired("grouped_with_metered_minimum_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency + + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = groupedWithMeteredMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { + if (!validated) { + cadence() + currency() + groupedWithMeteredMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21327,21 +27506,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21371,29 +27554,46 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedWithMeteredMinimumConfig( groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = groupedWithMeteredMinimumConfig(JsonField.of(groupedWithMeteredMinimumConfig)) + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -21401,13 +27601,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -21424,13 +27630,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -21439,10 +27651,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -21452,21 +27670,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -21481,22 +27707,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -21506,12 +27743,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -21520,6 +27765,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21655,6 +27907,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21774,22 +28034,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21799,8 +28081,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21812,10 +28094,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21932,22 +28221,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21957,8 +28268,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21971,10 +28282,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22100,6 +28418,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22180,96 +28506,227 @@ constructor( class NewFloatingMatrixWithDisplayNamePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), @JsonProperty("matrix_with_display_name_config") - private val matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @JsonProperty("matrix_with_display_name_config") - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = matrixWithDisplayNameConfig + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = + matrixWithDisplayNameConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { + if (!validated) { + cadence() + currency() + itemId() + matrixWithDisplayNameConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22279,21 +28736,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithDisplayNameConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22323,29 +28782,46 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } fun matrixWithDisplayNameConfig( matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -22353,13 +28829,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -22376,13 +28858,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -22391,10 +28879,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -22404,21 +28898,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -22433,22 +28935,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -22458,12 +28971,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -22472,6 +28993,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22607,6 +29135,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22725,22 +29261,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22750,8 +29308,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22763,10 +29321,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22883,22 +29448,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22908,8 +29495,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22922,10 +29509,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23051,6 +29645,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23132,95 +29734,224 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23230,21 +29961,23 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23272,30 +30005,46 @@ constructor( newFloatingBulkWithProrationPrice.additionalProperties.toMutableMap() } - fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -23303,13 +30052,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -23326,13 +30081,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -23341,10 +30102,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -23354,21 +30121,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -23383,22 +30158,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -23408,12 +30194,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -23422,6 +30216,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23476,6 +30277,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23674,22 +30483,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23699,8 +30530,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23712,10 +30543,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23832,22 +30670,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23857,8 +30717,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23871,10 +30731,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -24000,6 +30867,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24080,96 +30955,227 @@ constructor( class NewFloatingGroupedTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), @JsonProperty("grouped_tiered_package_config") - private val groupedTieredPackageConfig: GroupedTieredPackageConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** The id of the billable metric for the price. Only needed if the price is usage-based. */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** For custom cadence: specifies the duration of the billing period in days or months. */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** If the Price represents a fixed cost, this represents the quantity of units applied. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency @JsonProperty("grouped_tiered_package_config") - fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = groupedTieredPackageConfig + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = + groupedTieredPackageConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** The id of the billable metric for the price. Only needed if the price is usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** For custom cadence: specifies the duration of the billing period in days or months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** If the Price represents a fixed cost, this represents the quantity of units applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedTieredPackagePrice = apply { + if (!validated) { + cadence() + currency() + groupedTieredPackageConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24179,21 +31185,23 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedTieredPackageConfig: GroupedTieredPackageConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24223,30 +31231,45 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedTieredPackageConfig(groupedTieredPackageConfig: GroupedTieredPackageConfig) = - apply { - this.groupedTieredPackageConfig = groupedTieredPackageConfig - } + groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField + ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { this.modelType = modelType } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is usage-based. @@ -24254,13 +31277,19 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if this is * true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if this is @@ -24277,13 +31306,19 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this is + * true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or months. */ fun billingCycleConfiguration(billingCycleConfiguration: BillingCycleConfiguration?) = - apply { - this.billingCycleConfiguration = billingCycleConfiguration - } + billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or months. @@ -24292,10 +31327,16 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** The per unit conversion rate of the price currency to the invoicing currency. */ fun conversionRate(conversionRate: Double) = conversionRate(conversionRate as Double?) @@ -24305,21 +31346,29 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units applied. @@ -24334,22 +31383,33 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are produced. If * unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = invoicingCycleConfiguration(JsonField.ofNullable(invoicingCycleConfiguration)) /** * Within each billing cycle, specifies the cadence at which invoices are produced. If @@ -24359,12 +31419,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. If + * unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -24373,6 +31441,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24508,6 +31583,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24625,22 +31708,44 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24650,8 +31755,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24663,10 +31768,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -24783,22 +31895,44 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") @ExcludeMissing fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24808,8 +31942,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24822,10 +31956,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -24951,6 +32092,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt index 85f0b877..48bff5b7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,25 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * This endpoint is used to evaluate the output of a price for a given customer and time range. It + * enables filtering and grouping the output using + * [computed properties](../guides/extensibility/advanced-metrics#computed-properties), supporting + * the following workflows: + * 1. Showing detailed usage and costs to the end customer. + * 2. Auditing subtotals on invoice line items. + * + * For these workflows, the expressiveness of computed properties in both the filters and grouping + * is critical. For example, if you'd like to show your customer their usage grouped by hour and + * another property, you can do so with the following `grouping_keys`: + * `["hour_floor_timestamp_millis(timestamp_millis)", "my_property"]`. If you'd like to examine a + * customer's usage for a specific property value, you can do so with the following `filter`: + * `my_property = 'foo' AND my_other_property = 'bar'`. + * + * By default, the start of the time range must be no more than 100 days ago and the length of the + * results must be no greater than 1000. Note that this is a POST endpoint rather than a GET + * endpoint because it employs a JSON body rather than query parameters. + */ class PriceEvaluateParams constructor( private val priceId: String, @@ -52,12 +73,37 @@ constructor( */ fun groupingKeys(): Optional> = body.groupingKeys() - fun _additionalHeaders(): Headers = additionalHeaders + /** The exclusive upper bound for event timestamps */ + fun _timeframeEnd(): JsonField = body._timeframeEnd() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** The inclusive lower bound for event timestamps */ + fun _timeframeStart(): JsonField = body._timeframeStart() + + /** The ID of the customer to which this evaluation is scoped. */ + fun _customerId(): JsonField = body._customerId() + + /** The external customer ID of the customer to which this evaluation is scoped. */ + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + /** + * A boolean [computed property](../guides/extensibility/advanced-metrics#computed-properties) + * used to filter the underlying billable metric + */ + fun _filter(): JsonField = body._filter() + + /** + * Properties (or + * [computed properties](../guides/extensibility/advanced-metrics#computed-properties)) used to + * group the underlying billable metric + */ + fun _groupingKeys(): JsonField> = body._groupingKeys() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): PriceEvaluateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -75,36 +121,83 @@ constructor( class PriceEvaluateBody @JsonCreator internal constructor( - @JsonProperty("timeframe_end") private val timeframeEnd: OffsetDateTime, - @JsonProperty("timeframe_start") private val timeframeStart: OffsetDateTime, - @JsonProperty("customer_id") private val customerId: String?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("filter") private val filter: String?, - @JsonProperty("grouping_keys") private val groupingKeys: List?, + @JsonProperty("timeframe_end") + @ExcludeMissing + private val timeframeEnd: JsonField = JsonMissing.of(), + @JsonProperty("timeframe_start") + @ExcludeMissing + private val timeframeStart: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + private val filter: JsonField = JsonMissing.of(), + @JsonProperty("grouping_keys") + @ExcludeMissing + private val groupingKeys: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The exclusive upper bound for event timestamps */ - @JsonProperty("timeframe_end") fun timeframeEnd(): OffsetDateTime = timeframeEnd + fun timeframeEnd(): OffsetDateTime = timeframeEnd.getRequired("timeframe_end") /** The inclusive lower bound for event timestamps */ - @JsonProperty("timeframe_start") fun timeframeStart(): OffsetDateTime = timeframeStart + fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") + + /** The ID of the customer to which this evaluation is scoped. */ + fun customerId(): Optional = + Optional.ofNullable(customerId.getNullable("customer_id")) + + /** The external customer ID of the customer to which this evaluation is scoped. */ + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the underlying billable metric + */ + fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) + + /** + * Properties (or + * [computed properties](../guides/extensibility/advanced-metrics#computed-properties)) used + * to group the underlying billable metric + */ + fun groupingKeys(): Optional> = + Optional.ofNullable(groupingKeys.getNullable("grouping_keys")) + + /** The exclusive upper bound for event timestamps */ + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd + + /** The inclusive lower bound for event timestamps */ + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** The ID of the customer to which this evaluation is scoped. */ @JsonProperty("customer_id") - fun customerId(): Optional = Optional.ofNullable(customerId) + @ExcludeMissing + fun _customerId(): JsonField = customerId /** The external customer ID of the customer to which this evaluation is scoped. */ @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId /** * A boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to * filter the underlying billable metric */ - @JsonProperty("filter") fun filter(): Optional = Optional.ofNullable(filter) + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter /** * Properties (or @@ -112,12 +205,27 @@ constructor( * to group the underlying billable metric */ @JsonProperty("grouping_keys") - fun groupingKeys(): Optional> = Optional.ofNullable(groupingKeys) + @ExcludeMissing + fun _groupingKeys(): JsonField> = groupingKeys @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PriceEvaluateBody = apply { + if (!validated) { + timeframeEnd() + timeframeStart() + customerId() + externalCustomerId() + filter() + groupingKeys() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -127,12 +235,12 @@ constructor( class Builder { - private var timeframeEnd: OffsetDateTime? = null - private var timeframeStart: OffsetDateTime? = null - private var customerId: String? = null - private var externalCustomerId: String? = null - private var filter: String? = null - private var groupingKeys: MutableList? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var customerId: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var groupingKeys: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -142,41 +250,56 @@ constructor( customerId = priceEvaluateBody.customerId externalCustomerId = priceEvaluateBody.externalCustomerId filter = priceEvaluateBody.filter - groupingKeys = priceEvaluateBody.groupingKeys?.toMutableList() + groupingKeys = priceEvaluateBody.groupingKeys.map { it.toMutableList() } additionalProperties = priceEvaluateBody.additionalProperties.toMutableMap() } /** The exclusive upper bound for event timestamps */ - fun timeframeEnd(timeframeEnd: OffsetDateTime) = apply { + fun timeframeEnd(timeframeEnd: OffsetDateTime) = + timeframeEnd(JsonField.of(timeframeEnd)) + + /** The exclusive upper bound for event timestamps */ + fun timeframeEnd(timeframeEnd: JsonField) = apply { this.timeframeEnd = timeframeEnd } /** The inclusive lower bound for event timestamps */ - fun timeframeStart(timeframeStart: OffsetDateTime) = apply { + fun timeframeStart(timeframeStart: OffsetDateTime) = + timeframeStart(JsonField.of(timeframeStart)) + + /** The inclusive lower bound for event timestamps */ + fun timeframeStart(timeframeStart: JsonField) = apply { this.timeframeStart = timeframeStart } /** The ID of the customer to which this evaluation is scoped. */ - fun customerId(customerId: String?) = apply { this.customerId = customerId } + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) /** The ID of the customer to which this evaluation is scoped. */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** The ID of the customer to which this evaluation is scoped. */ + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** The external customer ID of the customer to which this evaluation is scoped. */ - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) /** The external customer ID of the customer to which this evaluation is scoped. */ fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** The external customer ID of the customer to which this evaluation is scoped. */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId + } + /** * A boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties) * used to filter the underlying billable metric */ - fun filter(filter: String?) = apply { this.filter = filter } + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) /** * A boolean @@ -185,22 +308,28 @@ constructor( */ fun filter(filter: Optional) = filter(filter.orElse(null)) + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) + * used to filter the underlying billable metric + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + /** * Properties (or * [computed properties](../guides/extensibility/advanced-metrics#computed-properties)) * used to group the underlying billable metric */ - fun groupingKeys(groupingKeys: List?) = apply { - this.groupingKeys = groupingKeys?.toMutableList() - } + fun groupingKeys(groupingKeys: List) = groupingKeys(JsonField.of(groupingKeys)) /** * Properties (or * [computed properties](../guides/extensibility/advanced-metrics#computed-properties)) * used to group the underlying billable metric */ - fun groupingKeys(groupingKeys: Optional>) = - groupingKeys(groupingKeys.orElse(null)) + fun groupingKeys(groupingKeys: JsonField>) = apply { + this.groupingKeys = groupingKeys.map { it.toMutableList() } + } /** * Properties (or @@ -208,7 +337,16 @@ constructor( * used to group the underlying billable metric */ fun addGroupingKey(groupingKey: String) = apply { - groupingKeys = (groupingKeys ?: mutableListOf()).apply { add(groupingKey) } + groupingKeys = + (groupingKeys ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(groupingKey) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -237,7 +375,7 @@ constructor( customerId, externalCustomerId, filter, - groupingKeys?.toImmutable(), + (groupingKeys ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -288,17 +426,30 @@ constructor( /** The exclusive upper bound for event timestamps */ fun timeframeEnd(timeframeEnd: OffsetDateTime) = apply { body.timeframeEnd(timeframeEnd) } + /** The exclusive upper bound for event timestamps */ + fun timeframeEnd(timeframeEnd: JsonField) = apply { + body.timeframeEnd(timeframeEnd) + } + /** The inclusive lower bound for event timestamps */ fun timeframeStart(timeframeStart: OffsetDateTime) = apply { body.timeframeStart(timeframeStart) } + /** The inclusive lower bound for event timestamps */ + fun timeframeStart(timeframeStart: JsonField) = apply { + body.timeframeStart(timeframeStart) + } + /** The ID of the customer to which this evaluation is scoped. */ fun customerId(customerId: String?) = apply { body.customerId(customerId) } /** The ID of the customer to which this evaluation is scoped. */ fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + /** The ID of the customer to which this evaluation is scoped. */ + fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + /** The external customer ID of the customer to which this evaluation is scoped. */ fun externalCustomerId(externalCustomerId: String?) = apply { body.externalCustomerId(externalCustomerId) @@ -308,6 +459,11 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + /** The external customer ID of the customer to which this evaluation is scoped. */ + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + /** * A boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to @@ -322,20 +478,28 @@ constructor( */ fun filter(filter: Optional) = filter(filter.orElse(null)) + /** + * A boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties) used to + * filter the underlying billable metric + */ + fun filter(filter: JsonField) = apply { body.filter(filter) } + /** * Properties (or * [computed properties](../guides/extensibility/advanced-metrics#computed-properties)) used * to group the underlying billable metric */ - fun groupingKeys(groupingKeys: List?) = apply { body.groupingKeys(groupingKeys) } + fun groupingKeys(groupingKeys: List) = apply { body.groupingKeys(groupingKeys) } /** * Properties (or * [computed properties](../guides/extensibility/advanced-metrics#computed-properties)) used * to group the underlying billable metric */ - fun groupingKeys(groupingKeys: Optional>) = - groupingKeys(groupingKeys.orElse(null)) + fun groupingKeys(groupingKeys: JsonField>) = apply { + body.groupingKeys(groupingKeys) + } /** * Properties (or @@ -344,6 +508,25 @@ constructor( */ fun addGroupingKey(groupingKey: String) = apply { body.addGroupingKey(groupingKey) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -442,25 +625,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): PriceEvaluateParams = PriceEvaluateParams( checkNotNull(priceId) { "`priceId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt index 60f9be4c..a90473e8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceEvaluateResponse.kt @@ -27,7 +27,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -51,18 +51,33 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(priceEvaluateResponse: PriceEvaluateResponse) = apply { - data = priceEvaluateResponse.data + data = priceEvaluateResponse.data.map { it.toMutableList() } additionalProperties = priceEvaluateResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: EvaluatePriceGroup) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -84,7 +99,11 @@ private constructor( } fun build(): PriceEvaluateResponse = - PriceEvaluateResponse(data.map { it.toImmutable() }, additionalProperties.toImmutable()) + PriceEvaluateResponse( + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt index 532272eb..5fc55321 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdFetchParams.kt @@ -7,6 +7,11 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint returns a price given an external price id. See the + * [price creation API](../reference/create-price) for more information about external price + * aliases. + */ class PriceExternalPriceIdFetchParams constructor( private val externalPriceId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt index 6544f8b4..6c718353 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceExternalPriceIdUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,10 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to update the `metadata` property on a price. If you pass null for the + * metadata value, it will clear any existing metadata for that price. + */ class PriceExternalPriceIdUpdateParams constructor( private val externalPriceId: String, @@ -33,12 +39,19 @@ constructor( */ fun metadata(): Optional = body.metadata() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): PriceExternalPriceIdUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -56,7 +69,9 @@ constructor( class PriceExternalPriceIdUpdateBody @JsonCreator internal constructor( - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -66,12 +81,28 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PriceExternalPriceIdUpdateBody = apply { + if (!validated) { + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -81,7 +112,7 @@ constructor( class Builder { - private var metadata: Metadata? = null + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -97,7 +128,7 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -106,6 +137,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -191,6 +229,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -289,25 +353,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): PriceExternalPriceIdUpdateParams = PriceExternalPriceIdUpdateParams( checkNotNull(externalPriceId) { "`externalPriceId` is required but was not set" }, @@ -334,6 +379,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt index 8272d633..49d820b1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceFetchParams.kt @@ -7,6 +7,7 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** This endpoint returns a price given an identifier. */ class PriceFetchParams constructor( private val priceId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt index c6492f28..9d144c9c 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceListParams.kt @@ -8,6 +8,10 @@ import com.withorb.api.core.http.QueryParams import java.util.Objects import java.util.Optional +/** + * This endpoint is used to list all add-on prices created using the + * [price creation endpoint](../reference/create-price). + */ class PriceListParams constructor( private val cursor: String?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt index 1ed43b2b..b819ba84 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/PriceUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,10 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint allows you to update the `metadata` property on a price. If you pass null for the + * metadata value, it will clear any existing metadata for that price. + */ class PriceUpdateParams constructor( private val priceId: String, @@ -33,12 +39,19 @@ constructor( */ fun metadata(): Optional = body.metadata() + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): PriceUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -56,7 +69,9 @@ constructor( class PriceUpdateBody @JsonCreator internal constructor( - @JsonProperty("metadata") private val metadata: Metadata?, + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -66,12 +81,28 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PriceUpdateBody = apply { + if (!validated) { + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -81,7 +112,7 @@ constructor( class Builder { - private var metadata: Metadata? = null + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -95,7 +126,7 @@ constructor( * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -104,6 +135,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -184,6 +222,32 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -282,25 +346,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): PriceUpdateParams = PriceUpdateParams( checkNotNull(priceId) { "`priceId` is required but was not set" }, @@ -327,6 +372,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt index 9a6688ed..6d7de6d7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscription.kt @@ -260,37 +260,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -299,7 +306,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -308,7 +315,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -328,7 +335,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -336,60 +343,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -437,40 +457,40 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscription: Subscription) = apply { id = subscription.id activePlanPhaseOrder = subscription.activePlanPhaseOrder - adjustmentIntervals = subscription.adjustmentIntervals + adjustmentIntervals = subscription.adjustmentIntervals.map { it.toMutableList() } autoCollection = subscription.autoCollection billingCycleAnchorConfiguration = subscription.billingCycleAnchorConfiguration billingCycleDay = subscription.billingCycleDay @@ -479,16 +499,17 @@ private constructor( currentBillingPeriodStartDate = subscription.currentBillingPeriodStartDate customer = subscription.customer defaultInvoiceMemo = subscription.defaultInvoiceMemo - discountIntervals = subscription.discountIntervals + discountIntervals = subscription.discountIntervals.map { it.toMutableList() } endDate = subscription.endDate - fixedFeeQuantitySchedule = subscription.fixedFeeQuantitySchedule + fixedFeeQuantitySchedule = + subscription.fixedFeeQuantitySchedule.map { it.toMutableList() } invoicingThreshold = subscription.invoicingThreshold - maximumIntervals = subscription.maximumIntervals + maximumIntervals = subscription.maximumIntervals.map { it.toMutableList() } metadata = subscription.metadata - minimumIntervals = subscription.minimumIntervals + minimumIntervals = subscription.minimumIntervals.map { it.toMutableList() } netTerms = subscription.netTerms plan = subscription.plan - priceIntervals = subscription.priceIntervals + priceIntervals = subscription.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscription.redeemedCoupon startDate = subscription.startDate status = subscription.status @@ -500,9 +521,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -515,15 +545,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -569,8 +630,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -587,8 +656,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -643,8 +720,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -660,11 +744,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -674,10 +775,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -689,7 +809,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -712,7 +846,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -751,11 +899,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -796,31 +961,55 @@ private constructor( fun build(): Subscription = Subscription( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -861,20 +1050,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -902,18 +1097,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -929,6 +1125,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -936,11 +1147,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -974,11 +1203,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1281,11 +1513,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1293,12 +1525,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1306,15 +1538,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1344,13 +1576,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1358,7 +1590,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1398,7 +1631,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1416,9 +1663,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1426,7 +1682,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1455,13 +1714,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1593,16 +1863,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1610,7 +1880,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1618,15 +1888,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1656,13 +1926,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1670,7 +1940,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1696,7 +1969,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1729,9 +2016,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1739,7 +2035,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1768,13 +2067,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1905,16 +2215,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1922,21 +2232,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1966,20 +2278,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -2005,7 +2318,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2023,9 +2350,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2033,7 +2369,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2077,13 +2416,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2220,16 +2570,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2237,24 +2587,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2285,21 +2637,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2325,7 +2678,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2364,9 +2731,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2374,7 +2750,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2403,14 +2782,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2541,16 +2931,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2558,21 +2948,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2602,20 +2994,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2640,7 +3033,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2673,9 +3080,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2683,7 +3099,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2712,13 +3131,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2851,19 +3281,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2889,7 +3319,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2924,7 +3354,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2936,7 +3379,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2965,7 +3421,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3217,25 +3673,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3264,19 +3728,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3299,7 +3765,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3309,9 +3789,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3320,7 +3815,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3357,12 +3855,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3485,25 +3991,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3532,18 +4044,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3558,7 +4074,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3568,9 +4098,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3579,7 +4124,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3629,12 +4177,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3760,26 +4316,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3808,18 +4372,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3833,7 +4399,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3843,9 +4423,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3854,7 +4449,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3906,12 +4504,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4015,13 +4621,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4048,10 +4658,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4063,7 +4673,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4102,10 +4714,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4175,24 +4787,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4220,17 +4838,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4243,7 +4862,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4253,11 +4886,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4305,11 +4956,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4459,24 +5116,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4504,17 +5167,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4527,7 +5191,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4537,11 +5215,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4589,11 +5285,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4928,10 +5630,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4940,7 +5644,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4949,13 +5653,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4963,7 +5670,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5193,13 +5901,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5230,15 +5940,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5248,7 +5959,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5272,8 +5984,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5289,8 +6009,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5305,7 +6034,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5318,8 +6053,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5327,7 +6070,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5789,6 +6554,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5824,14 +6654,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5859,11 +6698,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5889,9 +6730,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5942,9 +6783,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6009,11 +6852,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6039,9 +6886,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6056,7 +6903,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6087,9 +6936,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6189,7 +7038,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6213,7 +7064,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6222,7 +7073,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6245,7 +7098,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt index 3fd4cb69..40c49b19 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -20,6 +21,57 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * This endpoint can be used to cancel an existing subscription. It returns the serialized + * subscription object with an `end_date` parameter that signifies when the subscription will + * transition to an ended state. + * + * The body parameter `cancel_option` determines the cancellation behavior. Orb supports three + * cancellation options: + * - `end_of_subscription_term`: stops the subscription from auto-renewing. Subscriptions that have + * been cancelled with this option can still incur charges for the remainder of their term: + * - Issuing this cancellation request for a monthly subscription will keep the subscription + * active until the start of the subsequent month, and potentially issue an invoice for any + * usage charges incurred in the intervening period. + * - Issuing this cancellation request for a quarterly subscription will keep the subscription + * active until the end of the quarter and potentially issue an invoice for any usage charges + * incurred in the intervening period. + * - Issuing this cancellation request for a yearly subscription will keep the subscription + * active for the full year. For example, a yearly subscription starting on 2021-11-01 and + * cancelled on 2021-12-08 will remain active until 2022-11-01 and potentially issue charges + * in the intervening months for any recurring monthly usage charges in its plan. + * - **Note**: If a subscription's plan contains prices with difference cadences, the end of + * term date will be determined by the largest cadence value. For example, cancelling end of + * term for a subscription with a quarterly fixed fee with a monthly usage fee will result in + * the subscription ending at the end of the quarter. + * - `immediate`: ends the subscription immediately, setting the `end_date` to the current time: + * - Subscriptions that have been cancelled with this option will be invoiced immediately. This + * invoice will include any usage fees incurred in the billing period up to the cancellation, + * along with any prorated recurring fees for the billing period, if applicable. + * - **Note**: If the subscription has a recurring fee that was paid in-advance, the prorated + * amount for the remaining time period will be added to the + * [customer's balance](list-balance-transactions) upon immediate cancellation. However, if + * the customer is ineligible to use the customer balance, the subscription cannot be + * cancelled immediately. + * - `requested_date`: ends the subscription on a specified date, which requires a + * `cancellation_date` to be passed in. If no timezone is provided, the customer's timezone is + * used. For example, a subscription starting on January 1st with a monthly price can be set to be + * cancelled on the first of any month after January 1st (e.g. March 1st, April 1st, May 1st). A + * subscription with multiple prices with different cadences defines the "term" to be the highest + * cadence of the prices. + * + * Upcoming subscriptions are only eligible for immediate cancellation, which will set the + * `end_date` equal to the `start_date` upon cancellation. + * + * ## Backdated cancellations + * + * Orb allows you to cancel a subscription in the past as long as there are no paid invoices between + * the `requested_date` and the current time. If the cancellation is after the latest issued + * invoice, Orb will generate a balance refund for the current period. If the cancellation is before + * the most recently issued invoice, Orb will void the intervening invoice and generate a new one + * based on the new dates for the subscription. See the section on + * [cancellation behaviors](../guides/product-catalog/creating-subscriptions.md#cancellation-behaviors). + */ class SubscriptionCancelParams constructor( private val subscriptionId: String, @@ -39,12 +91,21 @@ constructor( */ fun cancellationDate(): Optional = body.cancellationDate() - fun _additionalHeaders(): Headers = additionalHeaders + /** Determines the timing of subscription cancellation */ + fun _cancelOption(): JsonField = body._cancelOption() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * The date that the cancellation should take effect. This parameter can only be passed if the + * `cancel_option` is `requested_date`. + */ + fun _cancellationDate(): JsonField = body._cancellationDate() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionCancelBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -62,26 +123,53 @@ constructor( class SubscriptionCancelBody @JsonCreator internal constructor( - @JsonProperty("cancel_option") private val cancelOption: CancelOption, - @JsonProperty("cancellation_date") private val cancellationDate: OffsetDateTime?, + @JsonProperty("cancel_option") + @ExcludeMissing + private val cancelOption: JsonField = JsonMissing.of(), + @JsonProperty("cancellation_date") + @ExcludeMissing + private val cancellationDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Determines the timing of subscription cancellation */ - @JsonProperty("cancel_option") fun cancelOption(): CancelOption = cancelOption + fun cancelOption(): CancelOption = cancelOption.getRequired("cancel_option") + + /** + * The date that the cancellation should take effect. This parameter can only be passed if + * the `cancel_option` is `requested_date`. + */ + fun cancellationDate(): Optional = + Optional.ofNullable(cancellationDate.getNullable("cancellation_date")) + + /** Determines the timing of subscription cancellation */ + @JsonProperty("cancel_option") + @ExcludeMissing + fun _cancelOption(): JsonField = cancelOption /** * The date that the cancellation should take effect. This parameter can only be passed if * the `cancel_option` is `requested_date`. */ @JsonProperty("cancellation_date") - fun cancellationDate(): Optional = Optional.ofNullable(cancellationDate) + @ExcludeMissing + fun _cancellationDate(): JsonField = cancellationDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionCancelBody = apply { + if (!validated) { + cancelOption() + cancellationDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -91,8 +179,8 @@ constructor( class Builder { - private var cancelOption: CancelOption? = null - private var cancellationDate: OffsetDateTime? = null + private var cancelOption: JsonField? = null + private var cancellationDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -103,7 +191,10 @@ constructor( } /** Determines the timing of subscription cancellation */ - fun cancelOption(cancelOption: CancelOption) = apply { + fun cancelOption(cancelOption: CancelOption) = cancelOption(JsonField.of(cancelOption)) + + /** Determines the timing of subscription cancellation */ + fun cancelOption(cancelOption: JsonField) = apply { this.cancelOption = cancelOption } @@ -111,9 +202,8 @@ constructor( * The date that the cancellation should take effect. This parameter can only be passed * if the `cancel_option` is `requested_date`. */ - fun cancellationDate(cancellationDate: OffsetDateTime?) = apply { - this.cancellationDate = cancellationDate - } + fun cancellationDate(cancellationDate: OffsetDateTime?) = + cancellationDate(JsonField.ofNullable(cancellationDate)) /** * The date that the cancellation should take effect. This parameter can only be passed @@ -122,6 +212,14 @@ constructor( fun cancellationDate(cancellationDate: Optional) = cancellationDate(cancellationDate.orElse(null)) + /** + * The date that the cancellation should take effect. This parameter can only be passed + * if the `cancel_option` is `requested_date`. + */ + fun cancellationDate(cancellationDate: JsonField) = apply { + this.cancellationDate = cancellationDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -195,6 +293,11 @@ constructor( /** Determines the timing of subscription cancellation */ fun cancelOption(cancelOption: CancelOption) = apply { body.cancelOption(cancelOption) } + /** Determines the timing of subscription cancellation */ + fun cancelOption(cancelOption: JsonField) = apply { + body.cancelOption(cancelOption) + } + /** * The date that the cancellation should take effect. This parameter can only be passed if * the `cancel_option` is `requested_date`. @@ -210,6 +313,33 @@ constructor( fun cancellationDate(cancellationDate: Optional) = cancellationDate(cancellationDate.orElse(null)) + /** + * The date that the cancellation should take effect. This parameter can only be passed if + * the `cancel_option` is `requested_date`. + */ + fun cancellationDate(cancellationDate: JsonField) = apply { + body.cancellationDate(cancellationDate) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -308,25 +438,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionCancelParams = SubscriptionCancelParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt index 6ce3c360..d81c38b4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCancelResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,40 +439,41 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscriptionCancelResponse: SubscriptionCancelResponse) = apply { id = subscriptionCancelResponse.id activePlanPhaseOrder = subscriptionCancelResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionCancelResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionCancelResponse.adjustmentIntervals.map { it.toMutableList() } autoCollection = subscriptionCancelResponse.autoCollection billingCycleAnchorConfiguration = subscriptionCancelResponse.billingCycleAnchorConfiguration @@ -462,16 +483,20 @@ private constructor( currentBillingPeriodStartDate = subscriptionCancelResponse.currentBillingPeriodStartDate customer = subscriptionCancelResponse.customer defaultInvoiceMemo = subscriptionCancelResponse.defaultInvoiceMemo - discountIntervals = subscriptionCancelResponse.discountIntervals + discountIntervals = + subscriptionCancelResponse.discountIntervals.map { it.toMutableList() } endDate = subscriptionCancelResponse.endDate - fixedFeeQuantitySchedule = subscriptionCancelResponse.fixedFeeQuantitySchedule + fixedFeeQuantitySchedule = + subscriptionCancelResponse.fixedFeeQuantitySchedule.map { it.toMutableList() } invoicingThreshold = subscriptionCancelResponse.invoicingThreshold - maximumIntervals = subscriptionCancelResponse.maximumIntervals + maximumIntervals = + subscriptionCancelResponse.maximumIntervals.map { it.toMutableList() } metadata = subscriptionCancelResponse.metadata - minimumIntervals = subscriptionCancelResponse.minimumIntervals + minimumIntervals = + subscriptionCancelResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionCancelResponse.netTerms plan = subscriptionCancelResponse.plan - priceIntervals = subscriptionCancelResponse.priceIntervals + priceIntervals = subscriptionCancelResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionCancelResponse.redeemedCoupon startDate = subscriptionCancelResponse.startDate status = subscriptionCancelResponse.status @@ -483,9 +508,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -498,15 +532,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -552,8 +617,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -570,8 +643,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -626,8 +707,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -643,11 +731,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -657,10 +762,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -672,7 +796,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -695,7 +833,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -734,11 +886,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -779,31 +948,55 @@ private constructor( fun build(): SubscriptionCancelResponse = SubscriptionCancelResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -844,20 +1037,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -885,18 +1084,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -912,6 +1112,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -919,11 +1134,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -957,11 +1190,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1264,11 +1500,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1276,12 +1512,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1289,15 +1525,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1327,13 +1563,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1341,7 +1577,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1381,7 +1618,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1399,9 +1650,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1409,7 +1669,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1438,13 +1701,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1576,16 +1850,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1593,7 +1867,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1601,15 +1875,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1639,13 +1913,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1653,7 +1927,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1679,7 +1956,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1712,9 +2003,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1722,7 +2022,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1751,13 +2054,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1888,16 +2202,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1905,21 +2219,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1949,20 +2265,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1988,7 +2305,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2006,9 +2337,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2016,7 +2356,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2060,13 +2403,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2203,16 +2557,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2220,24 +2574,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2268,21 +2624,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2308,7 +2665,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2347,9 +2718,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2357,7 +2737,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2386,14 +2769,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2524,16 +2918,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2541,21 +2935,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2585,20 +2981,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2623,7 +3020,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2656,9 +3067,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2666,7 +3086,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2695,13 +3118,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2834,19 +3268,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2872,7 +3306,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2907,7 +3341,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2919,7 +3366,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2948,7 +3408,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3200,25 +3660,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3247,19 +3715,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3282,7 +3752,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3292,9 +3776,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3303,7 +3802,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3340,12 +3842,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3468,25 +3978,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3515,18 +4031,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3541,7 +4061,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3551,9 +4085,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3562,7 +4111,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3612,12 +4164,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3743,26 +4303,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3791,18 +4359,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3816,7 +4386,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3826,9 +4410,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3837,7 +4436,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3889,12 +4491,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3998,13 +4608,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4031,10 +4645,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4046,7 +4660,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4085,10 +4701,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4158,24 +4774,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4203,17 +4825,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4226,7 +4849,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4236,11 +4873,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4288,11 +4943,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4442,24 +5103,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4487,17 +5154,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4510,7 +5178,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4520,11 +5202,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4572,11 +5272,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4911,10 +5617,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4923,7 +5631,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4932,13 +5640,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4946,7 +5657,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5176,13 +5888,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5213,15 +5927,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5231,7 +5946,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5255,8 +5971,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5272,8 +5996,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5288,7 +6021,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5301,8 +6040,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5310,7 +6057,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5772,6 +6541,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5807,14 +6641,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5842,11 +6685,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5872,9 +6717,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5925,9 +6770,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5992,11 +6839,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6022,9 +6873,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6039,7 +6890,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6070,9 +6923,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6172,7 +7025,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6196,7 +7051,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6205,7 +7060,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6228,7 +7085,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt index 0843d159..b02181a8 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -31,6 +32,236 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * A subscription represents the purchase of a plan by a customer. The customer is identified by + * either the `customer_id` or the `external_customer_id`, and exactly one of these fields must be + * provided. + * + * By default, subscriptions begin on the day that they're created and renew automatically for each + * billing cycle at the cadence that's configured in the plan definition. + * + * The default configuration for subscriptions in Orb is **In-advance billing** and **Beginning of + * month alignment** (see [Subscription](../guides/concepts#subscription) for more details). + * + * In order to change the alignment behavior, Orb also supports billing subscriptions on the day of + * the month they are created. If `align_billing_with_subscription_start_date = true` is specified, + * subscriptions have billing cycles that are aligned with their `start_date`. For example, a + * subscription that begins on January 15th will have a billing cycle from January 15th to February + * 15th. Every subsequent billing cycle will continue to start and invoice on the 15th. + * + * If the "day" value is greater than the number of days in the month, the next billing cycle will + * start at the end of the month. For example, if the start_date is January 31st, the next billing + * cycle will start on February 28th. + * + * If a customer was created with a currency, Orb only allows subscribing the customer to a plan + * with a matching `invoicing_currency`. If the customer does not have a currency set, on + * subscription creation, we set the customer's currency to be the `invoicing_currency` of the plan. + * + * ## Customize your customer's subscriptions + * + * Prices and adjustments in a plan can be added, removed, or replaced for the subscription being + * created. This is useful when a customer has prices that differ from the default prices for a + * specific plan. + * + * :::info This feature is only available for accounts that have migrated to Subscription Overrides + * Version 2. You can find your Subscription Overrides Version at the bottom of your + * [Plans page](https://app.withorb.com/plans) ::: + * + * ### Adding Prices + * + * To add prices, provide a list of objects with the key `add_prices`. An object in the list must + * specify an existing add-on price with a `price_id` or `external_price_id` field, or create a new + * add-on price by including an object with the key `price`, identical to what would be used in the + * request body for the [create price endpoint](../reference/create-price). See the + * [Price resource](../reference/price) for the specification of different price model + * configurations possible in this object. + * + * If the plan has phases, each object in the list must include a number with `plan_phase_order` key + * to indicate which phase the price should be added to. + * + * An object in the list can specify an optional `start_date` and optional `end_date`. This is + * equivalent to creating a price interval with the + * [add/edit price intervals endpoint](../reference/add-edit-price-intervals). If unspecified, the + * start or end date of the phase or subscription will be used. + * + * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or `discounts`. + * This will create adjustments which apply only to this price. + * + * Additionally, an object in the list can specify an optional `reference_id`. This ID can be used + * to reference this price when [adding an adjustment](#adding-adjustments) in the same API call. + * However the ID is _transient_ and cannot be used to refer to the price in future API calls. + * + * ### Removing Prices + * + * To remove prices, provide a list of objects with the key `remove_prices`. An object in the list + * must specify a plan price with either a `price_id` or `external_price_id` field. + * + * ### Replacing Prices + * + * To replace prices, provide a list of objects with the key `replace_prices`. An object in the list + * must specify a plan price to replace with the `replaces_price_id` key, and it must specify a + * price to replace it with by either referencing an existing add-on price with a `price_id` or + * `external_price_id` field, or by creating a new add-on price by including an object with the key + * `price`, identical to what would be used in the request body for the + * [create price endpoint](../reference/create-price). See the [Price resource](../reference/price) + * for the specification of different price model configurations possible in this object. + * + * For fixed fees, an object in the list can supply a `fixed_price_quantity` instead of a `price`, + * `price_id`, or `external_price_id` field. This will update only the quantity for the price, + * similar to the [Update price quantity](../reference/update-fixed-fee-quantity) endpoint. + * + * The replacement price will have the same phase, if applicable, and the same start and end dates + * as the price it replaces. + * + * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or `discounts`. + * This will create adjustments which apply only to this price. + * + * Additionally, an object in the list can specify an optional `reference_id`. This ID can be used + * to reference the replacement price when [adding an adjustment](#adding-adjustments) in the same + * API call. However the ID is _transient_ and cannot be used to refer to the price in future API + * calls. + * + * ### Adding adjustments + * + * To add adjustments, provide a list of objects with the key `add_adjustments`. An object in the + * list must include an object with the key `adjustment`, identical to the adjustment object in the + * [add/edit price intervals endpoint](../reference/add-edit-price-intervals). + * + * If the plan has phases, each object in the list must include a number with `plan_phase_order` key + * to indicate which phase the adjustment should be added to. + * + * An object in the list can specify an optional `start_date` and optional `end_date`. If + * unspecified, the start or end date of the phase or subscription will be used. + * + * ### Removing adjustments + * + * To remove adjustments, provide a list of objects with the key `remove_adjustments`. An object in + * the list must include a key, `adjustment_id`, with the ID of the adjustment to be removed. + * + * ### Replacing adjustments + * + * To replace adjustments, provide a list of objects with the key `replace_adjustments`. An object + * in the list must specify a plan adjustment to replace with the `replaces_adjustment_id` key, and + * it must specify an adjustment to replace it with by including an object with the key + * `adjustment`, identical to the adjustment object in the + * [add/edit price intervals endpoint](../reference/add-edit-price-intervals). + * + * The replacement adjustment will have the same phase, if applicable, and the same start and end + * dates as the adjustment it replaces. + * + * ## Price overrides (DEPRECATED) + * + * :::info Price overrides are being phased out in favor adding/removing/replacing prices. (See + * [Customize your customer's subscriptions](../reference/create-subscription#customize-your-customers-subscriptions)) + * ::: + * + * Price overrides are used to update some or all prices in a plan for the specific subscription + * being created. This is useful when a new customer has negotiated a rate that is unique to the + * customer. + * + * To override prices, provide a list of objects with the key `price_overrides`. The price object in + * the list of overrides is expected to contain the existing price id, the `model_type` and + * configuration. (See the [Price resource](../reference/price) for the specification of different + * price model configurations.) The numerical values can be updated, but the billable metric, + * cadence, type, and name of a price can not be overridden. + * + * ### Maximums and Minimums + * + * Minimums and maximums, much like price overrides, can be useful when a new customer has + * negotiated a new or different minimum or maximum spend cap than the default for a given price. If + * one exists for a price and null is provided for the minimum/maximum override on creation, then + * there will be no minimum/maximum on the new subscription. If no value is provided, then the + * default price maximum or minimum is used. + * + * To add a minimum for a specific price, add `minimum_amount` to the specific price in the + * `price_overrides` object. + * + * To add a maximum for a specific price, add `maximum_amount` to the specific price in the + * `price_overrides` object. + * + * ### Minimum override example + * + * Price minimum override example: + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * }, + * "minimum_amount": "100.00" + * ... + * } + * ``` + * + * Removing an existing minimum example + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * }, + * "minimum_amount": null + * ... + * } + * ``` + * + * ### Discounts + * + * Discounts, like price overrides, can be useful when a new customer has negotiated a new or + * different discount than the default for a price. If a discount exists for a price and a null + * discount is provided on creation, then there will be no discount on the new subscription. + * + * To add a discount for a specific price, add `discount` to the price in the `price_overrides` + * object. Discount should be a dictionary of the format: + * ```ts + * { + * "discount_type": "amount" | "percentage" | "usage", + * "amount_discount": string, + * "percentage_discount": string, + * "usage_discount": string + * } + * ``` + * + * where either `amount_discount`, `percentage_discount`, or `usage_discount` is provided. + * + * Price discount example + * + * ```json + * { + * ... + * "id": "price_id", + * "model_type": "unit", + * "unit_config": { + * "unit_amount": "0.50" + * }, + * "discount": {"discount_type": "amount", "amount_discount": "175"}, + * } + * ``` + * + * Removing an existing discount example + * + * ```json + * { + * "customer_id": "customer_id", + * "plan_id": "plan_id", + * "discount": null, + * "price_overrides": [ ... ] + * ... + * } + * ``` + * + * ## Threshold Billing + * + * Orb supports invoicing for a subscription when a preconfigured usage threshold is hit. To enable + * threshold billing, pass in an `invoicing_threshold`, which is specified in the subscription's + * invoicing currency, when creating a subscription. E.g. pass in `10.00` to issue an invoice when + * usage amounts hit $10.00 for a subscription that invoices in USD. + */ class SubscriptionCreateParams constructor( private val body: SubscriptionCreateBody, @@ -176,12 +407,151 @@ constructor( */ fun trialDurationDays(): Optional = body.trialDurationDays() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Additional adjustments to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun _addAdjustments(): JsonField> = body._addAdjustments() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Additional prices to be added to the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun _addPrices(): JsonField> = body._addPrices() + + fun _alignBillingWithSubscriptionStartDate(): JsonField = + body._alignBillingWithSubscriptionStartDate() + + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. If not specified, this defaults to the behavior + * configured for this customer. + */ + fun _autoCollection(): JsonField = body._autoCollection() + + fun _awsRegion(): JsonField = body._awsRegion() + + fun _billingCycleAnchorConfiguration(): JsonField = + body._billingCycleAnchorConfiguration() + + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by its + * redemption code, or cannot be redeemed, an error response will be returned and the + * subscription creation or plan change will not be scheduled. + */ + fun _couponRedemptionCode(): JsonField = body._couponRedemptionCode() + + fun _creditsOverageRate(): JsonField = body._creditsOverageRate() + + fun _customerId(): JsonField = body._customerId() + + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun _defaultInvoiceMemo(): JsonField = body._defaultInvoiceMemo() + + fun _endDate(): JsonField = body._endDate() + + fun _externalCustomerId(): JsonField = body._externalCustomerId() + + fun _externalMarketplace(): JsonField = body._externalMarketplace() + + fun _externalMarketplaceReportingId(): JsonField = + body._externalMarketplaceReportingId() + + /** + * The external_plan_id of the plan that the given subscription should be switched to. Note that + * either this property or `plan_id` must be specified. + */ + fun _externalPlanId(): JsonField = body._externalPlanId() + + /** + * An additional filter to apply to usage queries. This filter must be expressed as a boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If null, + * usage queries will not include any additional filter. + */ + fun _filter(): JsonField = body._filter() + + /** The phase of the plan to start with */ + fun _initialPhaseOrder(): JsonField = body._initialPhaseOrder() + + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued for + * the subscription. If not specified, invoices will only be issued at the end of the billing + * period. + */ + fun _invoicingThreshold(): JsonField = body._invoicingThreshold() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * The net terms determines the difference between the invoice date and the issue date for the + * invoice. If you intend the invoice to be due on issue, set this to 0. If not provided, this + * defaults to the value specified in the plan. + */ + fun _netTerms(): JsonField = body._netTerms() + + fun _perCreditOverageAmount(): JsonField = body._perCreditOverageAmount() + + /** + * The plan that the given subscription should be switched to. Note that either this property or + * `external_plan_id` must be specified. + */ + fun _planId(): JsonField = body._planId() + + /** + * Specifies which version of the plan to subscribe to. If null, the default version will be + * used. + */ + fun _planVersionNumber(): JsonField = body._planVersionNumber() + + /** Optionally provide a list of overrides for prices on the plan */ + fun _priceOverrides(): JsonField> = body._priceOverrides() + + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun _removeAdjustments(): JsonField> = body._removeAdjustments() + + /** + * Plan prices to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun _removePrices(): JsonField> = body._removePrices() + + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun _replaceAdjustments(): JsonField> = body._replaceAdjustments() + + /** + * Plan prices to be replaced with additional prices on the subscription. (Only available for + * accounts that have migrated off of legacy subscription overrides) + */ + fun _replacePrices(): JsonField> = body._replacePrices() + + fun _startDate(): JsonField = body._startDate() + + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun _trialDurationDays(): JsonField = body._trialDurationDays() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionCreateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -192,61 +562,291 @@ constructor( class SubscriptionCreateBody @JsonCreator internal constructor( - @JsonProperty("add_adjustments") private val addAdjustments: List?, - @JsonProperty("add_prices") private val addPrices: List?, + @JsonProperty("add_adjustments") + @ExcludeMissing + private val addAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("add_prices") + @ExcludeMissing + private val addPrices: JsonField> = JsonMissing.of(), @JsonProperty("align_billing_with_subscription_start_date") - private val alignBillingWithSubscriptionStartDate: Boolean?, - @JsonProperty("auto_collection") private val autoCollection: Boolean?, - @JsonProperty("aws_region") private val awsRegion: String?, + @ExcludeMissing + private val alignBillingWithSubscriptionStartDate: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("aws_region") + @ExcludeMissing + private val awsRegion: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_anchor_configuration") - private val billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration?, - @JsonProperty("coupon_redemption_code") private val couponRedemptionCode: String?, - @JsonProperty("credits_overage_rate") private val creditsOverageRate: Double?, - @JsonProperty("customer_id") private val customerId: String?, - @JsonProperty("default_invoice_memo") private val defaultInvoiceMemo: String?, - @JsonProperty("end_date") private val endDate: OffsetDateTime?, - @JsonProperty("external_customer_id") private val externalCustomerId: String?, - @JsonProperty("external_marketplace") private val externalMarketplace: ExternalMarketplace?, + @ExcludeMissing + private val billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("coupon_redemption_code") + @ExcludeMissing + private val couponRedemptionCode: JsonField = JsonMissing.of(), + @JsonProperty("credits_overage_rate") + @ExcludeMissing + private val creditsOverageRate: JsonField = JsonMissing.of(), + @JsonProperty("customer_id") + @ExcludeMissing + private val customerId: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_customer_id") + @ExcludeMissing + private val externalCustomerId: JsonField = JsonMissing.of(), + @JsonProperty("external_marketplace") + @ExcludeMissing + private val externalMarketplace: JsonField = JsonMissing.of(), @JsonProperty("external_marketplace_reporting_id") - private val externalMarketplaceReportingId: String?, - @JsonProperty("external_plan_id") private val externalPlanId: String?, - @JsonProperty("filter") private val filter: String?, - @JsonProperty("initial_phase_order") private val initialPhaseOrder: Long?, - @JsonProperty("invoicing_threshold") private val invoicingThreshold: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("net_terms") private val netTerms: Long?, - @JsonProperty("per_credit_overage_amount") private val perCreditOverageAmount: Double?, - @JsonProperty("plan_id") private val planId: String?, - @JsonProperty("plan_version_number") private val planVersionNumber: Long?, - @JsonProperty("price_overrides") private val priceOverrides: List?, - @JsonProperty("remove_adjustments") private val removeAdjustments: List?, - @JsonProperty("remove_prices") private val removePrices: List?, + @ExcludeMissing + private val externalMarketplaceReportingId: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + private val filter: JsonField = JsonMissing.of(), + @JsonProperty("initial_phase_order") + @ExcludeMissing + private val initialPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + private val invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("per_credit_overage_amount") + @ExcludeMissing + private val perCreditOverageAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_id") + @ExcludeMissing + private val planId: JsonField = JsonMissing.of(), + @JsonProperty("plan_version_number") + @ExcludeMissing + private val planVersionNumber: JsonField = JsonMissing.of(), + @JsonProperty("price_overrides") + @ExcludeMissing + private val priceOverrides: JsonField> = JsonMissing.of(), + @JsonProperty("remove_adjustments") + @ExcludeMissing + private val removeAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("remove_prices") + @ExcludeMissing + private val removePrices: JsonField> = JsonMissing.of(), @JsonProperty("replace_adjustments") - private val replaceAdjustments: List?, - @JsonProperty("replace_prices") private val replacePrices: List?, - @JsonProperty("start_date") private val startDate: OffsetDateTime?, - @JsonProperty("trial_duration_days") private val trialDurationDays: Long?, + @ExcludeMissing + private val replaceAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("replace_prices") + @ExcludeMissing + private val replacePrices: JsonField> = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("trial_duration_days") + @ExcludeMissing + private val trialDurationDays: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Additional adjustments to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun addAdjustments(): Optional> = + Optional.ofNullable(addAdjustments.getNullable("add_adjustments")) + + /** + * Additional prices to be added to the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun addPrices(): Optional> = + Optional.ofNullable(addPrices.getNullable("add_prices")) + + fun alignBillingWithSubscriptionStartDate(): Optional = + Optional.ofNullable( + alignBillingWithSubscriptionStartDate.getNullable( + "align_billing_with_subscription_start_date" + ) + ) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. If not specified, this defaults to the + * behavior configured for this customer. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + fun awsRegion(): Optional = Optional.ofNullable(awsRegion.getNullable("aws_region")) + + fun billingCycleAnchorConfiguration(): Optional = + Optional.ofNullable( + billingCycleAnchorConfiguration.getNullable("billing_cycle_anchor_configuration") + ) + + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by its + * redemption code, or cannot be redeemed, an error response will be returned and the + * subscription creation or plan change will not be scheduled. + */ + fun couponRedemptionCode(): Optional = + Optional.ofNullable(couponRedemptionCode.getNullable("coupon_redemption_code")) + + fun creditsOverageRate(): Optional = + Optional.ofNullable(creditsOverageRate.getNullable("credits_overage_rate")) + + fun customerId(): Optional = + Optional.ofNullable(customerId.getNullable("customer_id")) + + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + fun externalCustomerId(): Optional = + Optional.ofNullable(externalCustomerId.getNullable("external_customer_id")) + + fun externalMarketplace(): Optional = + Optional.ofNullable(externalMarketplace.getNullable("external_marketplace")) + + fun externalMarketplaceReportingId(): Optional = + Optional.ofNullable( + externalMarketplaceReportingId.getNullable("external_marketplace_reporting_id") + ) + + /** + * The external_plan_id of the plan that the given subscription should be switched to. Note + * that either this property or `plan_id` must be specified. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + /** + * An additional filter to apply to usage queries. This filter must be expressed as a + * boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If + * null, usage queries will not include any additional filter. + */ + fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) + + /** The phase of the plan to start with */ + fun initialPhaseOrder(): Optional = + Optional.ofNullable(initialPhaseOrder.getNullable("initial_phase_order")) + + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued + * for the subscription. If not specified, invoices will only be issued at the end of the + * billing period. + */ + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. If not + * provided, this defaults to the value specified in the plan. + */ + fun netTerms(): Optional = Optional.ofNullable(netTerms.getNullable("net_terms")) + + fun perCreditOverageAmount(): Optional = + Optional.ofNullable(perCreditOverageAmount.getNullable("per_credit_overage_amount")) + + /** + * The plan that the given subscription should be switched to. Note that either this + * property or `external_plan_id` must be specified. + */ + fun planId(): Optional = Optional.ofNullable(planId.getNullable("plan_id")) + + /** + * Specifies which version of the plan to subscribe to. If null, the default version will be + * used. + */ + fun planVersionNumber(): Optional = + Optional.ofNullable(planVersionNumber.getNullable("plan_version_number")) + + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(): Optional> = + Optional.ofNullable(priceOverrides.getNullable("price_overrides")) + + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun removeAdjustments(): Optional> = + Optional.ofNullable(removeAdjustments.getNullable("remove_adjustments")) + + /** + * Plan prices to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun removePrices(): Optional> = + Optional.ofNullable(removePrices.getNullable("remove_prices")) + + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun replaceAdjustments(): Optional> = + Optional.ofNullable(replaceAdjustments.getNullable("replace_adjustments")) + + /** + * Plan prices to be replaced with additional prices on the subscription. (Only available + * for accounts that have migrated off of legacy subscription overrides) + */ + fun replacePrices(): Optional> = + Optional.ofNullable(replacePrices.getNullable("replace_prices")) + + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun trialDurationDays(): Optional = + Optional.ofNullable(trialDurationDays.getNullable("trial_duration_days")) + /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ @JsonProperty("add_adjustments") - fun addAdjustments(): Optional> = Optional.ofNullable(addAdjustments) + @ExcludeMissing + fun _addAdjustments(): JsonField> = addAdjustments /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ @JsonProperty("add_prices") - fun addPrices(): Optional> = Optional.ofNullable(addPrices) + @ExcludeMissing + fun _addPrices(): JsonField> = addPrices @JsonProperty("align_billing_with_subscription_start_date") - fun alignBillingWithSubscriptionStartDate(): Optional = - Optional.ofNullable(alignBillingWithSubscriptionStartDate) + @ExcludeMissing + fun _alignBillingWithSubscriptionStartDate(): JsonField = + alignBillingWithSubscriptionStartDate /** * Determines whether issued invoices for this subscription will automatically be charged @@ -254,14 +854,15 @@ constructor( * behavior configured for this customer. */ @JsonProperty("auto_collection") - fun autoCollection(): Optional = Optional.ofNullable(autoCollection) + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection - @JsonProperty("aws_region") - fun awsRegion(): Optional = Optional.ofNullable(awsRegion) + @JsonProperty("aws_region") @ExcludeMissing fun _awsRegion(): JsonField = awsRegion @JsonProperty("billing_cycle_anchor_configuration") - fun billingCycleAnchorConfiguration(): Optional = - Optional.ofNullable(billingCycleAnchorConfiguration) + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * Redemption code to be used for this subscription. If the coupon cannot be found by its @@ -269,41 +870,48 @@ constructor( * subscription creation or plan change will not be scheduled. */ @JsonProperty("coupon_redemption_code") - fun couponRedemptionCode(): Optional = Optional.ofNullable(couponRedemptionCode) + @ExcludeMissing + fun _couponRedemptionCode(): JsonField = couponRedemptionCode @JsonProperty("credits_overage_rate") - fun creditsOverageRate(): Optional = Optional.ofNullable(creditsOverageRate) + @ExcludeMissing + fun _creditsOverageRate(): JsonField = creditsOverageRate @JsonProperty("customer_id") - fun customerId(): Optional = Optional.ofNullable(customerId) + @ExcludeMissing + fun _customerId(): JsonField = customerId /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. */ @JsonProperty("default_invoice_memo") - fun defaultInvoiceMemo(): Optional = Optional.ofNullable(defaultInvoiceMemo) + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo @JsonProperty("end_date") - fun endDate(): Optional = Optional.ofNullable(endDate) + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonProperty("external_customer_id") - fun externalCustomerId(): Optional = Optional.ofNullable(externalCustomerId) + @ExcludeMissing + fun _externalCustomerId(): JsonField = externalCustomerId @JsonProperty("external_marketplace") - fun externalMarketplace(): Optional = - Optional.ofNullable(externalMarketplace) + @ExcludeMissing + fun _externalMarketplace(): JsonField = externalMarketplace @JsonProperty("external_marketplace_reporting_id") - fun externalMarketplaceReportingId(): Optional = - Optional.ofNullable(externalMarketplaceReportingId) + @ExcludeMissing + fun _externalMarketplaceReportingId(): JsonField = externalMarketplaceReportingId /** * The external_plan_id of the plan that the given subscription should be switched to. Note * that either this property or `plan_id` must be specified. */ @JsonProperty("external_plan_id") - fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId /** * An additional filter to apply to usage queries. This filter must be expressed as a @@ -311,11 +919,12 @@ constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If * null, usage queries will not include any additional filter. */ - @JsonProperty("filter") fun filter(): Optional = Optional.ofNullable(filter) + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter /** The phase of the plan to start with */ @JsonProperty("initial_phase_order") - fun initialPhaseOrder(): Optional = Optional.ofNullable(initialPhaseOrder) + @ExcludeMissing + fun _initialPhaseOrder(): JsonField = initialPhaseOrder /** * When this subscription's accrued usage reaches this threshold, an invoice will be issued @@ -323,86 +932,132 @@ constructor( * billing period. */ @JsonProperty("invoicing_threshold") - fun invoicingThreshold(): Optional = Optional.ofNullable(invoicingThreshold) + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. If not * provided, this defaults to the value specified in the plan. */ - @JsonProperty("net_terms") fun netTerms(): Optional = Optional.ofNullable(netTerms) + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms @JsonProperty("per_credit_overage_amount") - fun perCreditOverageAmount(): Optional = Optional.ofNullable(perCreditOverageAmount) + @ExcludeMissing + fun _perCreditOverageAmount(): JsonField = perCreditOverageAmount /** * The plan that the given subscription should be switched to. Note that either this * property or `external_plan_id` must be specified. */ - @JsonProperty("plan_id") fun planId(): Optional = Optional.ofNullable(planId) + @JsonProperty("plan_id") @ExcludeMissing fun _planId(): JsonField = planId /** * Specifies which version of the plan to subscribe to. If null, the default version will be * used. */ @JsonProperty("plan_version_number") - fun planVersionNumber(): Optional = Optional.ofNullable(planVersionNumber) + @ExcludeMissing + fun _planVersionNumber(): JsonField = planVersionNumber /** Optionally provide a list of overrides for prices on the plan */ @JsonProperty("price_overrides") - fun priceOverrides(): Optional> = Optional.ofNullable(priceOverrides) + @ExcludeMissing + fun _priceOverrides(): JsonField> = priceOverrides /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ @JsonProperty("remove_adjustments") - fun removeAdjustments(): Optional> = - Optional.ofNullable(removeAdjustments) + @ExcludeMissing + fun _removeAdjustments(): JsonField> = removeAdjustments /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ @JsonProperty("remove_prices") - fun removePrices(): Optional> = Optional.ofNullable(removePrices) + @ExcludeMissing + fun _removePrices(): JsonField> = removePrices /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ @JsonProperty("replace_adjustments") - fun replaceAdjustments(): Optional> = - Optional.ofNullable(replaceAdjustments) + @ExcludeMissing + fun _replaceAdjustments(): JsonField> = replaceAdjustments /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ @JsonProperty("replace_prices") - fun replacePrices(): Optional> = Optional.ofNullable(replacePrices) + @ExcludeMissing + fun _replacePrices(): JsonField> = replacePrices @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * The duration of the trial period in days. If not provided, this defaults to the value * specified in the plan. If `0` is provided, the trial on the plan will be skipped. */ @JsonProperty("trial_duration_days") - fun trialDurationDays(): Optional = Optional.ofNullable(trialDurationDays) + @ExcludeMissing + fun _trialDurationDays(): JsonField = trialDurationDays @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionCreateBody = apply { + if (!validated) { + addAdjustments().map { it.forEach { it.validate() } } + addPrices().map { it.forEach { it.validate() } } + alignBillingWithSubscriptionStartDate() + autoCollection() + awsRegion() + billingCycleAnchorConfiguration().map { it.validate() } + couponRedemptionCode() + creditsOverageRate() + customerId() + defaultInvoiceMemo() + endDate() + externalCustomerId() + externalMarketplace() + externalMarketplaceReportingId() + externalPlanId() + filter() + initialPhaseOrder() + invoicingThreshold() + metadata().map { it.validate() } + netTerms() + perCreditOverageAmount() + planId() + planVersionNumber() + priceOverrides() + removeAdjustments().map { it.forEach { it.validate() } } + removePrices().map { it.forEach { it.validate() } } + replaceAdjustments().map { it.forEach { it.validate() } } + replacePrices().map { it.forEach { it.validate() } } + startDate() + trialDurationDays() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -412,42 +1067,44 @@ constructor( class Builder { - private var addAdjustments: MutableList? = null - private var addPrices: MutableList? = null - private var alignBillingWithSubscriptionStartDate: Boolean? = null - private var autoCollection: Boolean? = null - private var awsRegion: String? = null - private var billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? = null - private var couponRedemptionCode: String? = null - private var creditsOverageRate: Double? = null - private var customerId: String? = null - private var defaultInvoiceMemo: String? = null - private var endDate: OffsetDateTime? = null - private var externalCustomerId: String? = null - private var externalMarketplace: ExternalMarketplace? = null - private var externalMarketplaceReportingId: String? = null - private var externalPlanId: String? = null - private var filter: String? = null - private var initialPhaseOrder: Long? = null - private var invoicingThreshold: String? = null - private var metadata: Metadata? = null - private var netTerms: Long? = null - private var perCreditOverageAmount: Double? = null - private var planId: String? = null - private var planVersionNumber: Long? = null - private var priceOverrides: MutableList? = null - private var removeAdjustments: MutableList? = null - private var removePrices: MutableList? = null - private var replaceAdjustments: MutableList? = null - private var replacePrices: MutableList? = null - private var startDate: OffsetDateTime? = null - private var trialDurationDays: Long? = null + private var addAdjustments: JsonField>? = null + private var addPrices: JsonField>? = null + private var alignBillingWithSubscriptionStartDate: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var awsRegion: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: + JsonField = + JsonMissing.of() + private var couponRedemptionCode: JsonField = JsonMissing.of() + private var creditsOverageRate: JsonField = JsonMissing.of() + private var customerId: JsonField = JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var externalCustomerId: JsonField = JsonMissing.of() + private var externalMarketplace: JsonField = JsonMissing.of() + private var externalMarketplaceReportingId: JsonField = JsonMissing.of() + private var externalPlanId: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var initialPhaseOrder: JsonField = JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var perCreditOverageAmount: JsonField = JsonMissing.of() + private var planId: JsonField = JsonMissing.of() + private var planVersionNumber: JsonField = JsonMissing.of() + private var priceOverrides: JsonField>? = null + private var removeAdjustments: JsonField>? = null + private var removePrices: JsonField>? = null + private var replaceAdjustments: JsonField>? = null + private var replacePrices: JsonField>? = null + private var startDate: JsonField = JsonMissing.of() + private var trialDurationDays: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscriptionCreateBody: SubscriptionCreateBody) = apply { - addAdjustments = subscriptionCreateBody.addAdjustments?.toMutableList() - addPrices = subscriptionCreateBody.addPrices?.toMutableList() + addAdjustments = subscriptionCreateBody.addAdjustments.map { it.toMutableList() } + addPrices = subscriptionCreateBody.addPrices.map { it.toMutableList() } alignBillingWithSubscriptionStartDate = subscriptionCreateBody.alignBillingWithSubscriptionStartDate autoCollection = subscriptionCreateBody.autoCollection @@ -472,11 +1129,13 @@ constructor( perCreditOverageAmount = subscriptionCreateBody.perCreditOverageAmount planId = subscriptionCreateBody.planId planVersionNumber = subscriptionCreateBody.planVersionNumber - priceOverrides = subscriptionCreateBody.priceOverrides?.toMutableList() - removeAdjustments = subscriptionCreateBody.removeAdjustments?.toMutableList() - removePrices = subscriptionCreateBody.removePrices?.toMutableList() - replaceAdjustments = subscriptionCreateBody.replaceAdjustments?.toMutableList() - replacePrices = subscriptionCreateBody.replacePrices?.toMutableList() + priceOverrides = subscriptionCreateBody.priceOverrides.map { it.toMutableList() } + removeAdjustments = + subscriptionCreateBody.removeAdjustments.map { it.toMutableList() } + removePrices = subscriptionCreateBody.removePrices.map { it.toMutableList() } + replaceAdjustments = + subscriptionCreateBody.replaceAdjustments.map { it.toMutableList() } + replacePrices = subscriptionCreateBody.replacePrices.map { it.toMutableList() } startDate = subscriptionCreateBody.startDate trialDurationDays = subscriptionCreateBody.trialDurationDays additionalProperties = subscriptionCreateBody.additionalProperties.toMutableMap() @@ -486,9 +1145,8 @@ constructor( * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: List?) = apply { - this.addAdjustments = addAdjustments?.toMutableList() - } + fun addAdjustments(addAdjustments: List?) = + addAdjustments(JsonField.ofNullable(addAdjustments)) /** * Additional adjustments to be added to the subscription. (Only available for accounts @@ -497,21 +1155,36 @@ constructor( fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) + /** + * Additional adjustments to be added to the subscription. (Only available for accounts + * that have migrated off of legacy subscription overrides) + */ + fun addAdjustments(addAdjustments: JsonField>) = apply { + this.addAdjustments = addAdjustments.map { it.toMutableList() } + } + /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { - addAdjustments = (addAdjustments ?: mutableListOf()).apply { add(addAdjustment) } + addAdjustments = + (addAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addAdjustment) + } } /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: List?) = apply { - this.addPrices = addPrices?.toMutableList() - } + fun addPrices(addPrices: List?) = addPrices(JsonField.ofNullable(addPrices)) /** * Additional prices to be added to the subscription. (Only available for accounts that @@ -523,39 +1196,47 @@ constructor( * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addAddPrice(addPrice: AddPrice) = apply { - addPrices = (addPrices ?: mutableListOf()).apply { add(addPrice) } + fun addPrices(addPrices: JsonField>) = apply { + this.addPrices = addPrices.map { it.toMutableList() } } - fun alignBillingWithSubscriptionStartDate( - alignBillingWithSubscriptionStartDate: Boolean? - ) = apply { - this.alignBillingWithSubscriptionStartDate = alignBillingWithSubscriptionStartDate + /** + * Additional prices to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun addAddPrice(addPrice: AddPrice) = apply { + addPrices = + (addPrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addPrice) + } } fun alignBillingWithSubscriptionStartDate( alignBillingWithSubscriptionStartDate: Boolean ) = alignBillingWithSubscriptionStartDate( - alignBillingWithSubscriptionStartDate as Boolean? + JsonField.of(alignBillingWithSubscriptionStartDate) ) - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun alignBillingWithSubscriptionStartDate( - alignBillingWithSubscriptionStartDate: Optional - ) = - alignBillingWithSubscriptionStartDate( - alignBillingWithSubscriptionStartDate.orElse(null) as Boolean? - ) + alignBillingWithSubscriptionStartDate: JsonField + ) = apply { + this.alignBillingWithSubscriptionStartDate = alignBillingWithSubscriptionStartDate + } /** * Determines whether issued invoices for this subscription will automatically be * charged with the saved payment method on the due date. If not specified, this * defaults to the behavior configured for this customer. */ - fun autoCollection(autoCollection: Boolean?) = apply { - this.autoCollection = autoCollection - } + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) /** * Determines whether issued invoices for this subscription will automatically be @@ -573,26 +1254,43 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) - fun awsRegion(awsRegion: String?) = apply { this.awsRegion = awsRegion } + /** + * Determines whether issued invoices for this subscription will automatically be + * charged with the saved payment method on the due date. If not specified, this + * defaults to the behavior configured for this customer. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + + fun awsRegion(awsRegion: String?) = awsRegion(JsonField.ofNullable(awsRegion)) fun awsRegion(awsRegion: Optional) = awsRegion(awsRegion.orElse(null)) + fun awsRegion(awsRegion: JsonField) = apply { this.awsRegion = awsRegion } + fun billingCycleAnchorConfiguration( billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + ) = + billingCycleAnchorConfiguration( + JsonField.ofNullable(billingCycleAnchorConfiguration) + ) fun billingCycleAnchorConfiguration( billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + /** * Redemption code to be used for this subscription. If the coupon cannot be found by * its redemption code, or cannot be redeemed, an error response will be returned and * the subscription creation or plan change will not be scheduled. */ - fun couponRedemptionCode(couponRedemptionCode: String?) = apply { - this.couponRedemptionCode = couponRedemptionCode - } + fun couponRedemptionCode(couponRedemptionCode: String?) = + couponRedemptionCode(JsonField.ofNullable(couponRedemptionCode)) /** * Redemption code to be used for this subscription. If the coupon cannot be found by @@ -602,10 +1300,18 @@ constructor( fun couponRedemptionCode(couponRedemptionCode: Optional) = couponRedemptionCode(couponRedemptionCode.orElse(null)) - fun creditsOverageRate(creditsOverageRate: Double?) = apply { - this.creditsOverageRate = creditsOverageRate + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by + * its redemption code, or cannot be redeemed, an error response will be returned and + * the subscription creation or plan change will not be scheduled. + */ + fun couponRedemptionCode(couponRedemptionCode: JsonField) = apply { + this.couponRedemptionCode = couponRedemptionCode } + fun creditsOverageRate(creditsOverageRate: Double?) = + creditsOverageRate(JsonField.ofNullable(creditsOverageRate)) + fun creditsOverageRate(creditsOverageRate: Double) = creditsOverageRate(creditsOverageRate as Double?) @@ -613,17 +1319,22 @@ constructor( fun creditsOverageRate(creditsOverageRate: Optional) = creditsOverageRate(creditsOverageRate.orElse(null) as Double?) - fun customerId(customerId: String?) = apply { this.customerId = customerId } + fun creditsOverageRate(creditsOverageRate: JsonField) = apply { + this.creditsOverageRate = creditsOverageRate + } + + fun customerId(customerId: String?) = customerId(JsonField.ofNullable(customerId)) fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + fun customerId(customerId: JsonField) = apply { this.customerId = customerId } + /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) /** * Determines the default memo on this subscription's invoices. Note that if this is not @@ -632,38 +1343,57 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) - fun endDate(endDate: OffsetDateTime?) = apply { this.endDate = endDate } + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - fun externalCustomerId(externalCustomerId: String?) = apply { - this.externalCustomerId = externalCustomerId - } + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + + fun externalCustomerId(externalCustomerId: String?) = + externalCustomerId(JsonField.ofNullable(externalCustomerId)) fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) - fun externalMarketplace(externalMarketplace: ExternalMarketplace?) = apply { - this.externalMarketplace = externalMarketplace + fun externalCustomerId(externalCustomerId: JsonField) = apply { + this.externalCustomerId = externalCustomerId } + fun externalMarketplace(externalMarketplace: ExternalMarketplace?) = + externalMarketplace(JsonField.ofNullable(externalMarketplace)) + fun externalMarketplace(externalMarketplace: Optional) = externalMarketplace(externalMarketplace.orElse(null)) - fun externalMarketplaceReportingId(externalMarketplaceReportingId: String?) = apply { - this.externalMarketplaceReportingId = externalMarketplaceReportingId + fun externalMarketplace(externalMarketplace: JsonField) = apply { + this.externalMarketplace = externalMarketplace } + fun externalMarketplaceReportingId(externalMarketplaceReportingId: String?) = + externalMarketplaceReportingId(JsonField.ofNullable(externalMarketplaceReportingId)) + fun externalMarketplaceReportingId(externalMarketplaceReportingId: Optional) = externalMarketplaceReportingId(externalMarketplaceReportingId.orElse(null)) + fun externalMarketplaceReportingId(externalMarketplaceReportingId: JsonField) = + apply { + this.externalMarketplaceReportingId = externalMarketplaceReportingId + } + /** * The external_plan_id of the plan that the given subscription should be switched to. * Note that either this property or `plan_id` must be specified. */ - fun externalPlanId(externalPlanId: String?) = apply { - this.externalPlanId = externalPlanId - } + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) /** * The external_plan_id of the plan that the given subscription should be switched to. @@ -672,13 +1402,21 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * The external_plan_id of the plan that the given subscription should be switched to. + * Note that either this property or `plan_id` must be specified. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + /** * An additional filter to apply to usage queries. This filter must be expressed as a * boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If * null, usage queries will not include any additional filter. */ - fun filter(filter: String?) = apply { this.filter = filter } + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) /** * An additional filter to apply to usage queries. This filter must be expressed as a @@ -688,10 +1426,17 @@ constructor( */ fun filter(filter: Optional) = filter(filter.orElse(null)) + /** + * An additional filter to apply to usage queries. This filter must be expressed as a + * boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If + * null, usage queries will not include any additional filter. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + /** The phase of the plan to start with */ - fun initialPhaseOrder(initialPhaseOrder: Long?) = apply { - this.initialPhaseOrder = initialPhaseOrder - } + fun initialPhaseOrder(initialPhaseOrder: Long?) = + initialPhaseOrder(JsonField.ofNullable(initialPhaseOrder)) /** The phase of the plan to start with */ fun initialPhaseOrder(initialPhaseOrder: Long) = @@ -702,14 +1447,18 @@ constructor( fun initialPhaseOrder(initialPhaseOrder: Optional) = initialPhaseOrder(initialPhaseOrder.orElse(null) as Long?) + /** The phase of the plan to start with */ + fun initialPhaseOrder(initialPhaseOrder: JsonField) = apply { + this.initialPhaseOrder = initialPhaseOrder + } + /** * When this subscription's accrued usage reaches this threshold, an invoice will be * issued for the subscription. If not specified, invoices will only be issued at the * end of the billing period. */ - fun invoicingThreshold(invoicingThreshold: String?) = apply { - this.invoicingThreshold = invoicingThreshold - } + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) /** * When this subscription's accrued usage reaches this threshold, an invoice will be @@ -719,12 +1468,21 @@ constructor( fun invoicingThreshold(invoicingThreshold: Optional) = invoicingThreshold(invoicingThreshold.orElse(null)) + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be + * issued for the subscription. If not specified, invoices will only be issued at the + * end of the billing period. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -733,12 +1491,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. If not * provided, this defaults to the value specified in the plan. */ - fun netTerms(netTerms: Long?) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) /** * The net terms determines the difference between the invoice date and the issue date @@ -755,9 +1520,15 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) - fun perCreditOverageAmount(perCreditOverageAmount: Double?) = apply { - this.perCreditOverageAmount = perCreditOverageAmount - } + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. If not + * provided, this defaults to the value specified in the plan. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun perCreditOverageAmount(perCreditOverageAmount: Double?) = + perCreditOverageAmount(JsonField.ofNullable(perCreditOverageAmount)) fun perCreditOverageAmount(perCreditOverageAmount: Double) = perCreditOverageAmount(perCreditOverageAmount as Double?) @@ -766,11 +1537,15 @@ constructor( fun perCreditOverageAmount(perCreditOverageAmount: Optional) = perCreditOverageAmount(perCreditOverageAmount.orElse(null) as Double?) + fun perCreditOverageAmount(perCreditOverageAmount: JsonField) = apply { + this.perCreditOverageAmount = perCreditOverageAmount + } + /** * The plan that the given subscription should be switched to. Note that either this * property or `external_plan_id` must be specified. */ - fun planId(planId: String?) = apply { this.planId = planId } + fun planId(planId: String?) = planId(JsonField.ofNullable(planId)) /** * The plan that the given subscription should be switched to. Note that either this @@ -778,13 +1553,18 @@ constructor( */ fun planId(planId: Optional) = planId(planId.orElse(null)) + /** + * The plan that the given subscription should be switched to. Note that either this + * property or `external_plan_id` must be specified. + */ + fun planId(planId: JsonField) = apply { this.planId = planId } + /** * Specifies which version of the plan to subscribe to. If null, the default version * will be used. */ - fun planVersionNumber(planVersionNumber: Long?) = apply { - this.planVersionNumber = planVersionNumber - } + fun planVersionNumber(planVersionNumber: Long?) = + planVersionNumber(JsonField.ofNullable(planVersionNumber)) /** * Specifies which version of the plan to subscribe to. If null, the default version @@ -801,27 +1581,47 @@ constructor( fun planVersionNumber(planVersionNumber: Optional) = planVersionNumber(planVersionNumber.orElse(null) as Long?) - /** Optionally provide a list of overrides for prices on the plan */ - fun priceOverrides(priceOverrides: List?) = apply { - this.priceOverrides = priceOverrides?.toMutableList() + /** + * Specifies which version of the plan to subscribe to. If null, the default version + * will be used. + */ + fun planVersionNumber(planVersionNumber: JsonField) = apply { + this.planVersionNumber = planVersionNumber } + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(priceOverrides: List?) = + priceOverrides(JsonField.ofNullable(priceOverrides)) + /** Optionally provide a list of overrides for prices on the plan */ fun priceOverrides(priceOverrides: Optional>) = priceOverrides(priceOverrides.orElse(null)) + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(priceOverrides: JsonField>) = apply { + this.priceOverrides = priceOverrides.map { it.toMutableList() } + } + /** Optionally provide a list of overrides for prices on the plan */ fun addPriceOverride(priceOverride: JsonValue) = apply { - priceOverrides = (priceOverrides ?: mutableListOf()).apply { add(priceOverride) } + priceOverrides = + (priceOverrides ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceOverride) + } } /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: List?) = apply { - this.removeAdjustments = removeAdjustments?.toMutableList() - } + fun removeAdjustments(removeAdjustments: List?) = + removeAdjustments(JsonField.ofNullable(removeAdjustments)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts @@ -830,22 +1630,37 @@ constructor( fun removeAdjustments(removeAdjustments: Optional>) = removeAdjustments(removeAdjustments.orElse(null)) + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts + * that have migrated off of legacy subscription overrides) + */ + fun removeAdjustments(removeAdjustments: JsonField>) = apply { + this.removeAdjustments = removeAdjustments.map { it.toMutableList() } + } + /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ fun addRemoveAdjustment(removeAdjustment: RemoveAdjustment) = apply { removeAdjustments = - (removeAdjustments ?: mutableListOf()).apply { add(removeAdjustment) } + (removeAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeAdjustment) + } } /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: List?) = apply { - this.removePrices = removePrices?.toMutableList() - } + fun removePrices(removePrices: List?) = + removePrices(JsonField.ofNullable(removePrices)) /** * Plan prices to be removed from the subscription. (Only available for accounts that @@ -854,21 +1669,37 @@ constructor( fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) + /** + * Plan prices to be removed from the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun removePrices(removePrices: JsonField>) = apply { + this.removePrices = removePrices.map { it.toMutableList() } + } + /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ fun addRemovePrice(removePrice: RemovePrice) = apply { - removePrices = (removePrices ?: mutableListOf()).apply { add(removePrice) } + removePrices = + (removePrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removePrice) + } } /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: List?) = apply { - this.replaceAdjustments = replaceAdjustments?.toMutableList() - } + fun replaceAdjustments(replaceAdjustments: List?) = + replaceAdjustments(JsonField.ofNullable(replaceAdjustments)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. @@ -877,22 +1708,37 @@ constructor( fun replaceAdjustments(replaceAdjustments: Optional>) = replaceAdjustments(replaceAdjustments.orElse(null)) + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. + * (Only available for accounts that have migrated off of legacy subscription overrides) + */ + fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { + this.replaceAdjustments = replaceAdjustments.map { it.toMutableList() } + } + /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ fun addReplaceAdjustment(replaceAdjustment: ReplaceAdjustment) = apply { replaceAdjustments = - (replaceAdjustments ?: mutableListOf()).apply { add(replaceAdjustment) } + (replaceAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(replaceAdjustment) + } } /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: List?) = apply { - this.replacePrices = replacePrices?.toMutableList() - } + fun replacePrices(replacePrices: List?) = + replacePrices(JsonField.ofNullable(replacePrices)) /** * Plan prices to be replaced with additional prices on the subscription. (Only @@ -901,25 +1747,45 @@ constructor( fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) + /** + * Plan prices to be replaced with additional prices on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun replacePrices(replacePrices: JsonField>) = apply { + this.replacePrices = replacePrices.map { it.toMutableList() } + } + /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ fun addReplacePrice(replacePrice: ReplacePrice) = apply { - replacePrices = (replacePrices ?: mutableListOf()).apply { add(replacePrice) } + replacePrices = + (replacePrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(replacePrice) + } } - fun startDate(startDate: OffsetDateTime?) = apply { this.startDate = startDate } + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + /** * The duration of the trial period in days. If not provided, this defaults to the value * specified in the plan. If `0` is provided, the trial on the plan will be skipped. */ - fun trialDurationDays(trialDurationDays: Long?) = apply { - this.trialDurationDays = trialDurationDays - } + fun trialDurationDays(trialDurationDays: Long?) = + trialDurationDays(JsonField.ofNullable(trialDurationDays)) /** * The duration of the trial period in days. If not provided, this defaults to the value @@ -936,6 +1802,14 @@ constructor( fun trialDurationDays(trialDurationDays: Optional) = trialDurationDays(trialDurationDays.orElse(null) as Long?) + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun trialDurationDays(trialDurationDays: JsonField) = apply { + this.trialDurationDays = trialDurationDays + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -957,8 +1831,8 @@ constructor( fun build(): SubscriptionCreateBody = SubscriptionCreateBody( - addAdjustments?.toImmutable(), - addPrices?.toImmutable(), + (addAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (addPrices ?: JsonMissing.of()).map { it.toImmutable() }, alignBillingWithSubscriptionStartDate, autoCollection, awsRegion, @@ -980,11 +1854,11 @@ constructor( perCreditOverageAmount, planId, planVersionNumber, - priceOverrides?.toImmutable(), - removeAdjustments?.toImmutable(), - removePrices?.toImmutable(), - replaceAdjustments?.toImmutable(), - replacePrices?.toImmutable(), + (priceOverrides ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (removePrices ?: JsonMissing.of()).map { it.toImmutable() }, + (replaceAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (replacePrices ?: JsonMissing.of()).map { it.toImmutable() }, startDate, trialDurationDays, additionalProperties.toImmutable(), @@ -1045,6 +1919,14 @@ constructor( fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) + /** + * Additional adjustments to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun addAdjustments(addAdjustments: JsonField>) = apply { + body.addAdjustments(addAdjustments) + } + /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) @@ -1065,27 +1947,28 @@ constructor( */ fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + /** + * Additional prices to be added to the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun addPrices(addPrices: JsonField>) = apply { body.addPrices(addPrices) } + /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ fun addAddPrice(addPrice: AddPrice) = apply { body.addAddPrice(addPrice) } - fun alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate: Boolean?) = + fun alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate: Boolean) = apply { body.alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate) } - fun alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate: Boolean) = - alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate as Boolean?) - - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun alignBillingWithSubscriptionStartDate( - alignBillingWithSubscriptionStartDate: Optional - ) = - alignBillingWithSubscriptionStartDate( - alignBillingWithSubscriptionStartDate.orElse(null) as Boolean? - ) + alignBillingWithSubscriptionStartDate: JsonField + ) = apply { + body.alignBillingWithSubscriptionStartDate(alignBillingWithSubscriptionStartDate) + } /** * Determines whether issued invoices for this subscription will automatically be charged @@ -1110,10 +1993,21 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. If not specified, this defaults to the + * behavior configured for this customer. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + fun awsRegion(awsRegion: String?) = apply { body.awsRegion(awsRegion) } fun awsRegion(awsRegion: Optional) = awsRegion(awsRegion.orElse(null)) + fun awsRegion(awsRegion: JsonField) = apply { body.awsRegion(awsRegion) } + fun billingCycleAnchorConfiguration( billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } @@ -1122,6 +2016,10 @@ constructor( billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } + /** * Redemption code to be used for this subscription. If the coupon cannot be found by its * redemption code, or cannot be redeemed, an error response will be returned and the @@ -1139,6 +2037,15 @@ constructor( fun couponRedemptionCode(couponRedemptionCode: Optional) = couponRedemptionCode(couponRedemptionCode.orElse(null)) + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by its + * redemption code, or cannot be redeemed, an error response will be returned and the + * subscription creation or plan change will not be scheduled. + */ + fun couponRedemptionCode(couponRedemptionCode: JsonField) = apply { + body.couponRedemptionCode(couponRedemptionCode) + } + fun creditsOverageRate(creditsOverageRate: Double?) = apply { body.creditsOverageRate(creditsOverageRate) } @@ -1150,10 +2057,16 @@ constructor( fun creditsOverageRate(creditsOverageRate: Optional) = creditsOverageRate(creditsOverageRate.orElse(null) as Double?) + fun creditsOverageRate(creditsOverageRate: JsonField) = apply { + body.creditsOverageRate(creditsOverageRate) + } + fun customerId(customerId: String?) = apply { body.customerId(customerId) } fun customerId(customerId: Optional) = customerId(customerId.orElse(null)) + fun customerId(customerId: JsonField) = apply { body.customerId(customerId) } + /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. @@ -1169,10 +2082,20 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + body.defaultInvoiceMemo(defaultInvoiceMemo) + } + fun endDate(endDate: OffsetDateTime?) = apply { body.endDate(endDate) } fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + fun endDate(endDate: JsonField) = apply { body.endDate(endDate) } + fun externalCustomerId(externalCustomerId: String?) = apply { body.externalCustomerId(externalCustomerId) } @@ -1180,6 +2103,10 @@ constructor( fun externalCustomerId(externalCustomerId: Optional) = externalCustomerId(externalCustomerId.orElse(null)) + fun externalCustomerId(externalCustomerId: JsonField) = apply { + body.externalCustomerId(externalCustomerId) + } + fun externalMarketplace(externalMarketplace: ExternalMarketplace?) = apply { body.externalMarketplace(externalMarketplace) } @@ -1187,6 +2114,10 @@ constructor( fun externalMarketplace(externalMarketplace: Optional) = externalMarketplace(externalMarketplace.orElse(null)) + fun externalMarketplace(externalMarketplace: JsonField) = apply { + body.externalMarketplace(externalMarketplace) + } + fun externalMarketplaceReportingId(externalMarketplaceReportingId: String?) = apply { body.externalMarketplaceReportingId(externalMarketplaceReportingId) } @@ -1194,6 +2125,11 @@ constructor( fun externalMarketplaceReportingId(externalMarketplaceReportingId: Optional) = externalMarketplaceReportingId(externalMarketplaceReportingId.orElse(null)) + fun externalMarketplaceReportingId(externalMarketplaceReportingId: JsonField) = + apply { + body.externalMarketplaceReportingId(externalMarketplaceReportingId) + } + /** * The external_plan_id of the plan that the given subscription should be switched to. Note * that either this property or `plan_id` must be specified. @@ -1207,6 +2143,14 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * The external_plan_id of the plan that the given subscription should be switched to. Note + * that either this property or `plan_id` must be specified. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + body.externalPlanId(externalPlanId) + } + /** * An additional filter to apply to usage queries. This filter must be expressed as a * boolean @@ -1223,6 +2167,14 @@ constructor( */ fun filter(filter: Optional) = filter(filter.orElse(null)) + /** + * An additional filter to apply to usage queries. This filter must be expressed as a + * boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If + * null, usage queries will not include any additional filter. + */ + fun filter(filter: JsonField) = apply { body.filter(filter) } + /** The phase of the plan to start with */ fun initialPhaseOrder(initialPhaseOrder: Long?) = apply { body.initialPhaseOrder(initialPhaseOrder) @@ -1237,6 +2189,11 @@ constructor( fun initialPhaseOrder(initialPhaseOrder: Optional) = initialPhaseOrder(initialPhaseOrder.orElse(null) as Long?) + /** The phase of the plan to start with */ + fun initialPhaseOrder(initialPhaseOrder: JsonField) = apply { + body.initialPhaseOrder(initialPhaseOrder) + } + /** * When this subscription's accrued usage reaches this threshold, an invoice will be issued * for the subscription. If not specified, invoices will only be issued at the end of the @@ -1254,6 +2211,15 @@ constructor( fun invoicingThreshold(invoicingThreshold: Optional) = invoicingThreshold(invoicingThreshold.orElse(null)) + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued + * for the subscription. If not specified, invoices will only be issued at the end of the + * billing period. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + body.invoicingThreshold(invoicingThreshold) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -1268,6 +2234,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. If not @@ -1290,6 +2263,13 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. If not + * provided, this defaults to the value specified in the plan. + */ + fun netTerms(netTerms: JsonField) = apply { body.netTerms(netTerms) } + fun perCreditOverageAmount(perCreditOverageAmount: Double?) = apply { body.perCreditOverageAmount(perCreditOverageAmount) } @@ -1301,6 +2281,10 @@ constructor( fun perCreditOverageAmount(perCreditOverageAmount: Optional) = perCreditOverageAmount(perCreditOverageAmount.orElse(null) as Double?) + fun perCreditOverageAmount(perCreditOverageAmount: JsonField) = apply { + body.perCreditOverageAmount(perCreditOverageAmount) + } + /** * The plan that the given subscription should be switched to. Note that either this * property or `external_plan_id` must be specified. @@ -1313,6 +2297,12 @@ constructor( */ fun planId(planId: Optional) = planId(planId.orElse(null)) + /** + * The plan that the given subscription should be switched to. Note that either this + * property or `external_plan_id` must be specified. + */ + fun planId(planId: JsonField) = apply { body.planId(planId) } + /** * Specifies which version of the plan to subscribe to. If null, the default version will be * used. @@ -1336,6 +2326,14 @@ constructor( fun planVersionNumber(planVersionNumber: Optional) = planVersionNumber(planVersionNumber.orElse(null) as Long?) + /** + * Specifies which version of the plan to subscribe to. If null, the default version will be + * used. + */ + fun planVersionNumber(planVersionNumber: JsonField) = apply { + body.planVersionNumber(planVersionNumber) + } + /** Optionally provide a list of overrides for prices on the plan */ fun priceOverrides(priceOverrides: List?) = apply { body.priceOverrides(priceOverrides) @@ -1345,6 +2343,11 @@ constructor( fun priceOverrides(priceOverrides: Optional>) = priceOverrides(priceOverrides.orElse(null)) + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(priceOverrides: JsonField>) = apply { + body.priceOverrides(priceOverrides) + } + /** Optionally provide a list of overrides for prices on the plan */ fun addPriceOverride(priceOverride: JsonValue) = apply { body.addPriceOverride(priceOverride) @@ -1365,6 +2368,14 @@ constructor( fun removeAdjustments(removeAdjustments: Optional>) = removeAdjustments(removeAdjustments.orElse(null)) + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun removeAdjustments(removeAdjustments: JsonField>) = apply { + body.removeAdjustments(removeAdjustments) + } + /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) @@ -1388,6 +2399,14 @@ constructor( fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) + /** + * Plan prices to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun removePrices(removePrices: JsonField>) = apply { + body.removePrices(removePrices) + } + /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) @@ -1409,6 +2428,14 @@ constructor( fun replaceAdjustments(replaceAdjustments: Optional>) = replaceAdjustments(replaceAdjustments.orElse(null)) + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { + body.replaceAdjustments(replaceAdjustments) + } + /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) @@ -1432,6 +2459,14 @@ constructor( fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) + /** + * Plan prices to be replaced with additional prices on the subscription. (Only available + * for accounts that have migrated off of legacy subscription overrides) + */ + fun replacePrices(replacePrices: JsonField>) = apply { + body.replacePrices(replacePrices) + } + /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) @@ -1444,6 +2479,8 @@ constructor( fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { body.startDate(startDate) } + /** * The duration of the trial period in days. If not provided, this defaults to the value * specified in the plan. If `0` is provided, the trial on the plan will be skipped. @@ -1467,6 +2504,33 @@ constructor( fun trialDurationDays(trialDurationDays: Optional) = trialDurationDays(trialDurationDays.orElse(null) as Long?) + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun trialDurationDays(trialDurationDays: JsonField) = apply { + body.trialDurationDays(trialDurationDays) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -1565,25 +2629,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionCreateParams = SubscriptionCreateParams( body.build(), @@ -1596,16 +2641,49 @@ constructor( class AddAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment") private val adjustment: Adjustment, - @JsonProperty("end_date") private val endDate: OffsetDateTime?, - @JsonProperty("plan_phase_order") private val planPhaseOrder: Long?, - @JsonProperty("start_date") private val startDate: OffsetDateTime?, + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") fun adjustment(): Adjustment = adjustment + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. If null, the adjustment will start when the phase + * or subscription starts. + */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The phase to add this adjustment to. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when the + * phase or subscription starts. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** * The end date of the adjustment interval. This is the date that the adjustment will stop @@ -1613,11 +2691,13 @@ constructor( * or subscription starts. */ @JsonProperty("end_date") - fun endDate(): Optional = Optional.ofNullable(endDate) + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The phase to add this adjustment to. */ @JsonProperty("plan_phase_order") - fun planPhaseOrder(): Optional = Optional.ofNullable(planPhaseOrder) + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** * The start date of the adjustment interval. This is the date that the adjustment will @@ -1625,12 +2705,25 @@ constructor( * phase or subscription starts. */ @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddAdjustment = apply { + if (!validated) { + adjustment() + endDate() + planPhaseOrder() + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1640,10 +2733,10 @@ constructor( class Builder { - private var adjustment: Adjustment? = null - private var endDate: OffsetDateTime? = null - private var planPhaseOrder: Long? = null - private var startDate: OffsetDateTime? = null + private var adjustment: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1656,34 +2749,34 @@ constructor( } /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = apply { this.adjustment = adjustment } + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = apply { - this.adjustment = Adjustment.ofNewPercentageDiscount(newPercentageDiscount) + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment } - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = apply { - this.adjustment = Adjustment.ofNewUsageDiscount(newUsageDiscount) - } + fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = + adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = apply { - this.adjustment = Adjustment.ofNewAmountDiscount(newAmountDiscount) - } + fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = + adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - fun adjustment(newMinimum: Adjustment.NewMinimum) = apply { - this.adjustment = Adjustment.ofNewMinimum(newMinimum) - } + fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = + adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - fun adjustment(newMaximum: Adjustment.NewMaximum) = apply { - this.adjustment = Adjustment.ofNewMaximum(newMaximum) - } + fun adjustment(newMinimum: Adjustment.NewMinimum) = + adjustment(Adjustment.ofNewMinimum(newMinimum)) + + fun adjustment(newMaximum: Adjustment.NewMaximum) = + adjustment(Adjustment.ofNewMaximum(newMaximum)) /** * The end date of the adjustment interval. This is the date that the adjustment will * stop affecting prices on the subscription. If null, the adjustment will start when * the phase or subscription starts. */ - fun endDate(endDate: OffsetDateTime?) = apply { this.endDate = endDate } + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) /** * The end date of the adjustment interval. This is the date that the adjustment will @@ -1692,10 +2785,16 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. If null, the adjustment will start when + * the phase or subscription starts. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) /** The phase to add this adjustment to. */ fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) @@ -1705,12 +2804,17 @@ constructor( fun planPhaseOrder(planPhaseOrder: Optional) = planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + /** The phase to add this adjustment to. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + /** * The start date of the adjustment interval. This is the date that the adjustment will * start affecting prices on the subscription. If null, the adjustment will start when * the phase or subscription starts. */ - fun startDate(startDate: OffsetDateTime?) = apply { this.startDate = startDate } + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) /** * The start date of the adjustment interval. This is the date that the adjustment will @@ -1719,6 +2823,15 @@ constructor( */ fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when + * the phase or subscription starts. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1761,6 +2874,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newPercentageDiscount(): Optional = Optional.ofNullable(newPercentageDiscount) @@ -1811,6 +2926,26 @@ constructor( } } + fun validate(): Adjustment = apply { + if (!validated) { + if ( + newPercentageDiscount == null && + newUsageDiscount == null && + newAmountDiscount == null && + newMinimum == null && + newMaximum == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + newPercentageDiscount?.validate() + newUsageDiscount?.validate() + newAmountDiscount?.validate() + newMinimum?.validate() + newMaximum?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1880,29 +3015,40 @@ constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newPercentageDiscount = it, _json = json) + } } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newUsageDiscount = it, _json = json) + } } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newAmountDiscount = it, _json = json) + } } "minimum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMinimum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMinimum = it, _json = json) + } } "maximum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMaximum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMaximum = it, _json = json) + } } } @@ -1936,35 +3082,75 @@ constructor( class NewPercentageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPercentageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + percentageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1974,47 +3160,58 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var percentageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var percentageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = newPercentageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } percentageDiscount = newPercentageDiscount.percentageDiscount isInvoiceLevel = newPercentageDiscount.isInvoiceLevel additionalProperties = newPercentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun percentageDiscount(percentageDiscount: Double) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount } /** @@ -2022,15 +3219,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2062,7 +3259,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(percentageDiscount) { "`percentageDiscount` is required but was not set" }, @@ -2145,34 +3342,74 @@ constructor( class NewUsageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("usage_discount") private val usageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("usage_discount") fun usageDiscount(): Double = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewUsageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + usageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2182,46 +3419,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var usageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var usageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newUsageDiscount: NewUsageDiscount) = apply { adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = newUsageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } usageDiscount = newUsageDiscount.usageDiscount isInvoiceLevel = newUsageDiscount.isInvoiceLevel additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun usageDiscount(usageDiscount: Double) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount } /** @@ -2229,15 +3477,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2269,7 +3517,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(usageDiscount) { "`usageDiscount` is required but was not set" }, @@ -2352,34 +3600,74 @@ constructor( class NewAmountDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("amount_discount") private val amountDiscount: String, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType - @JsonProperty("amount_discount") fun amountDiscount(): String = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAmountDiscount = apply { + if (!validated) { + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2389,46 +3677,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var amountDiscount: String? = null - private var appliesToPriceIds: MutableList? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newAmountDiscount: NewAmountDiscount) = apply { adjustmentType = newAmountDiscount.adjustmentType amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = newAmountDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = newAmountDiscount.isInvoiceLevel additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } - fun amountDiscount(amountDiscount: String) = apply { + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2436,15 +3735,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2479,7 +3778,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, isInvoiceLevel, additionalProperties.toImmutable(), ) @@ -2559,38 +3858,84 @@ constructor( class NewMinimum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMinimum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + itemId() + minimumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2600,51 +3945,64 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var itemId: String? = null - private var minimumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMinimum: NewMinimum) = apply { adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } itemId = newMinimum.itemId minimumAmount = newMinimum.minimumAmount isInvoiceLevel = newMinimum.isInvoiceLevel additionalProperties = newMinimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun minimumAmount(minimumAmount: String) = apply { - this.minimumAmount = minimumAmount - } + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** @@ -2652,15 +4010,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2692,7 +4050,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" @@ -2776,34 +4134,74 @@ constructor( class NewMaximum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("maximum_amount") private val maximumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("maximum_amount") fun maximumAmount(): String = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMaximum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + maximumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2813,46 +4211,56 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var maximumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMaximum: NewMaximum) = apply { adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = newMaximum.maximumAmount isInvoiceLevel = newMaximum.isInvoiceLevel additionalProperties = newMaximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun maximumAmount(maximumAmount: String) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** @@ -2860,15 +4268,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2900,7 +4308,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, @@ -3002,71 +4410,161 @@ constructor( class AddPrice @JsonCreator private constructor( - @JsonProperty("discounts") private val discounts: List?, - @JsonProperty("end_date") private val endDate: OffsetDateTime?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("minimum_amount") private val minimumAmount: String?, - @JsonProperty("plan_phase_order") private val planPhaseOrder: Long?, - @JsonProperty("price") private val price: Price?, - @JsonProperty("price_id") private val priceId: String?, - @JsonProperty("start_date") private val startDate: OffsetDateTime?, + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. + */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** + * The end date of the price interval. This is the date that the price will stop billing on + * the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The phase to add this price to. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** + * The start date of the price interval. This is the date that the price will start billing + * on the subscription. If null, billing will start when the phase or subscription starts. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. */ @JsonProperty("discounts") - fun discounts(): Optional> = Optional.ofNullable(discounts) + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** * The end date of the price interval. This is the date that the price will stop billing on * the subscription. If null, billing will end when the phase or subscription ends. */ @JsonProperty("end_date") - fun endDate(): Optional = Optional.ofNullable(endDate) + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The external price id of the price to add to the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this * price. */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. */ @JsonProperty("minimum_amount") - fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount) + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The phase to add this price to. */ @JsonProperty("plan_phase_order") - fun planPhaseOrder(): Optional = Optional.ofNullable(planPhaseOrder) + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") fun price(): Optional = Optional.ofNullable(price) + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId /** * The start date of the price interval. This is the date that the price will start billing * on the subscription. If null, billing will start when the phase or subscription starts. */ @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddPrice = apply { + if (!validated) { + discounts().map { it.forEach { it.validate() } } + endDate() + externalPriceId() + maximumAmount() + minimumAmount() + planPhaseOrder() + price() + priceId() + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3076,20 +4574,20 @@ constructor( class Builder { - private var discounts: MutableList? = null - private var endDate: OffsetDateTime? = null - private var externalPriceId: String? = null - private var maximumAmount: String? = null - private var minimumAmount: String? = null - private var planPhaseOrder: Long? = null - private var price: Price? = null - private var priceId: String? = null - private var startDate: OffsetDateTime? = null + private var discounts: JsonField>? = null + private var endDate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addPrice: AddPrice) = apply { - discounts = addPrice.discounts?.toMutableList() + discounts = addPrice.discounts.map { it.toMutableList() } endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount @@ -3105,9 +4603,7 @@ constructor( * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this * price. */ - fun discounts(discounts: List?) = apply { - this.discounts = discounts?.toMutableList() - } + fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this @@ -3115,19 +4611,36 @@ constructor( */ fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this + * price. + */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this * price. */ fun addDiscount(discount: Discount) = apply { - discounts = (discounts ?: mutableListOf()).apply { add(discount) } + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** * The end date of the price interval. This is the date that the price will stop billing * on the subscription. If null, billing will end when the phase or subscription ends. */ - fun endDate(endDate: OffsetDateTime?) = apply { this.endDate = endDate } + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) /** * The end date of the price interval. This is the date that the price will stop billing @@ -3135,20 +4648,31 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + /** + * The end date of the price interval. This is the date that the price will stop billing + * on the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to add to the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this * price. */ - fun maximumAmount(maximumAmount: String?) = apply { this.maximumAmount = maximumAmount } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this @@ -3157,11 +4681,20 @@ constructor( fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. */ - fun minimumAmount(minimumAmount: String?) = apply { this.minimumAmount = minimumAmount } + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this @@ -3170,11 +4703,18 @@ constructor( fun minimumAmount(minimumAmount: Optional) = minimumAmount(minimumAmount.orElse(null)) - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = apply { - this.planPhaseOrder = planPhaseOrder + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) @@ -3183,144 +4723,144 @@ constructor( fun planPhaseOrder(planPhaseOrder: Optional) = planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = apply { this.price = price } + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** The definition of a new price to create and add to the subscription. */ fun price(price: Optional) = price(price.orElse(null)) - fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = apply { - this.price = Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice) - } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } - fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = apply { - this.price = Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice) - } + fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = + price(Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice)) - fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = apply { - this.price = Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice) - } + fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = + price(Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice)) - fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = apply { - this.price = Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice) - } + fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = + price(Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice)) - fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = apply { - this.price = Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice) - } + fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = + price(Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice)) - fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice) - } + fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = + price(Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice)) - fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice) - } + fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = + price(Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice)) - fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = apply { - this.price = Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice) - } + fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = + price(Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice)) + + fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = + price(Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice)) fun price( newSubscriptionThresholdTotalAmountPrice: Price.NewSubscriptionThresholdTotalAmountPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionThresholdTotalAmountPrice( newSubscriptionThresholdTotalAmountPrice ) - } + ) fun price(newSubscriptionTieredPackagePrice: Price.NewSubscriptionTieredPackagePrice) = - apply { - this.price = - Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice) - } + price(Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice)) fun price( newSubscriptionTieredWithMinimumPrice: Price.NewSubscriptionTieredWithMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTieredWithMinimumPrice( newSubscriptionTieredWithMinimumPrice ) - } + ) fun price( newSubscriptionUnitWithPercentPrice: Price.NewSubscriptionUnitWithPercentPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithPercentPrice(newSubscriptionUnitWithPercentPrice) - } + ) fun price( newSubscriptionPackageWithAllocationPrice: Price.NewSubscriptionPackageWithAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionPackageWithAllocationPrice( newSubscriptionPackageWithAllocationPrice ) - } + ) fun price( newSubscriptionTierWithProrationPrice: Price.NewSubscriptionTierWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTierWithProrationPrice( newSubscriptionTierWithProrationPrice ) - } + ) fun price( newSubscriptionUnitWithProrationPrice: Price.NewSubscriptionUnitWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithProrationPrice( newSubscriptionUnitWithProrationPrice ) - } + ) fun price( newSubscriptionGroupedAllocationPrice: Price.NewSubscriptionGroupedAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedAllocationPrice( newSubscriptionGroupedAllocationPrice ) - } + ) fun price( newSubscriptionGroupedWithProratedMinimumPrice: Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedWithProratedMinimumPrice( newSubscriptionGroupedWithProratedMinimumPrice ) - } + ) fun price( newSubscriptionBulkWithProrationPrice: Price.NewSubscriptionBulkWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionBulkWithProrationPrice( newSubscriptionBulkWithProrationPrice ) - } + ) /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to add to the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to add to the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** * The start date of the price interval. This is the date that the price will start * billing on the subscription. If null, billing will start when the phase or * subscription starts. */ - fun startDate(startDate: OffsetDateTime?) = apply { this.startDate = startDate } + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) /** * The start date of the price interval. This is the date that the price will start @@ -3329,6 +4869,15 @@ constructor( */ fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + /** + * The start date of the price interval. This is the date that the price will start + * billing on the subscription. If null, billing will start when the phase or + * subscription starts. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3350,7 +4899,7 @@ constructor( fun build(): AddPrice = AddPrice( - discounts?.toImmutable(), + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, endDate, externalPriceId, maximumAmount, @@ -3367,37 +4916,81 @@ constructor( class Discount @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("amount_discount") private val amountDiscount: String?, - @JsonProperty("percentage_discount") private val percentageDiscount: Double?, - @JsonProperty("usage_discount") private val usageDiscount: Double?, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount.getNullable("amount_discount")) + + /** + * Only available if discount_type is `percentage`. This is a number between 0 and 1. + */ + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + fun usageDiscount(): Optional = + Optional.ofNullable(usageDiscount.getNullable("usage_discount")) + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** Only available if discount_type is `amount`. */ @JsonProperty("amount_discount") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** * Only available if discount_type is `percentage`. This is a number between 0 and 1. */ @JsonProperty("percentage_discount") - fun percentageDiscount(): Optional = Optional.ofNullable(percentageDiscount) + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ @JsonProperty("usage_discount") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Discount = apply { + if (!validated) { + discountType() + amountDiscount() + percentageDiscount() + usageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3407,10 +5000,10 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var amountDiscount: String? = null - private var percentageDiscount: Double? = null - private var usageDiscount: Double? = null + private var discountType: JsonField? = null + private var amountDiscount: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3422,26 +5015,32 @@ constructor( additionalProperties = discount.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = apply { - this.amountDiscount = amountDiscount - } + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) /** Only available if discount_type is `amount`. */ fun amountDiscount(amountDiscount: Optional) = amountDiscount(amountDiscount.orElse(null)) + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + /** * Only available if discount_type is `percentage`. This is a number between 0 * and 1. */ - fun percentageDiscount(percentageDiscount: Double?) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double?) = + percentageDiscount(JsonField.ofNullable(percentageDiscount)) /** * Only available if discount_type is `percentage`. This is a number between 0 @@ -3458,13 +5057,20 @@ constructor( fun percentageDiscount(percentageDiscount: Optional) = percentageDiscount(percentageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + /** * Only available if discount_type is `usage`. Number of usage units that this * discount is for */ - fun usageDiscount(usageDiscount: Double?) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double?) = + usageDiscount(JsonField.ofNullable(usageDiscount)) /** * Only available if discount_type is `usage`. Number of usage units that this @@ -3480,6 +5086,14 @@ constructor( fun usageDiscount(usageDiscount: Optional) = usageDiscount(usageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3637,6 +5251,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newSubscriptionUnitPrice(): Optional = Optional.ofNullable(newSubscriptionUnitPrice) @@ -3885,6 +5501,52 @@ constructor( } } + fun validate(): Price = apply { + if (!validated) { + if ( + newSubscriptionUnitPrice == null && + newSubscriptionPackagePrice == null && + newSubscriptionMatrixPrice == null && + newSubscriptionTieredPrice == null && + newSubscriptionTieredBpsPrice == null && + newSubscriptionBpsPrice == null && + newSubscriptionBulkBpsPrice == null && + newSubscriptionBulkPrice == null && + newSubscriptionThresholdTotalAmountPrice == null && + newSubscriptionTieredPackagePrice == null && + newSubscriptionTieredWithMinimumPrice == null && + newSubscriptionUnitWithPercentPrice == null && + newSubscriptionPackageWithAllocationPrice == null && + newSubscriptionTierWithProrationPrice == null && + newSubscriptionUnitWithProrationPrice == null && + newSubscriptionGroupedAllocationPrice == null && + newSubscriptionGroupedWithProratedMinimumPrice == null && + newSubscriptionBulkWithProrationPrice == null + ) { + throw OrbInvalidDataException("Unknown Price: $_json") + } + newSubscriptionUnitPrice?.validate() + newSubscriptionPackagePrice?.validate() + newSubscriptionMatrixPrice?.validate() + newSubscriptionTieredPrice?.validate() + newSubscriptionTieredBpsPrice?.validate() + newSubscriptionBpsPrice?.validate() + newSubscriptionBulkBpsPrice?.validate() + newSubscriptionBulkPrice?.validate() + newSubscriptionThresholdTotalAmountPrice?.validate() + newSubscriptionTieredPackagePrice?.validate() + newSubscriptionTieredWithMinimumPrice?.validate() + newSubscriptionUnitWithPercentPrice?.validate() + newSubscriptionPackageWithAllocationPrice?.validate() + newSubscriptionTierWithProrationPrice?.validate() + newSubscriptionUnitWithProrationPrice?.validate() + newSubscriptionGroupedAllocationPrice?.validate() + newSubscriptionGroupedWithProratedMinimumPrice?.validate() + newSubscriptionBulkWithProrationPrice?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4153,55 +5815,76 @@ constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionUnitPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionUnitPrice = it, _json = json) + } } "package" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionPackagePrice = it, _json = json) } } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionMatrixPrice = it, _json = json) } } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredPrice = it, _json = json) } } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredBpsPrice = it, _json = json) } } "bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBpsPrice = it, _json = json) + } } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionBulkBpsPrice = it, _json = json) } } "bulk" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBulkPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBulkPrice = it, _json = json) + } } "threshold_total_amount" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionThresholdTotalAmountPrice = it, @@ -4213,7 +5896,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredPackagePrice = it, @@ -4225,7 +5910,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredWithMinimumPrice = it, @@ -4237,7 +5924,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithPercentPrice = it, @@ -4249,7 +5938,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionPackageWithAllocationPrice = it, @@ -4261,7 +5952,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTierWithProrationPrice = it, @@ -4273,7 +5966,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithProrationPrice = it, @@ -4285,7 +5980,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedAllocationPrice = it, @@ -4297,7 +5994,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedWithProratedMinimumPrice = it, @@ -4309,7 +6008,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionBulkWithProrationPrice = it, @@ -4379,96 +6080,229 @@ constructor( class NewSubscriptionUnitPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -4476,19 +6310,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4498,22 +6358,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4541,25 +6404,41 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -4568,13 +6447,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -4591,13 +6477,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -4607,12 +6501,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -4627,11 +6528,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -4639,22 +6547,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -4671,22 +6588,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -4696,12 +6628,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -4710,11 +6650,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -4723,6 +6671,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4905,18 +6861,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4926,7 +6898,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4937,7 +6909,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -4996,22 +6973,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5021,8 +7022,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -5036,10 +7037,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5160,22 +7168,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5185,8 +7217,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -5201,10 +7233,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5334,6 +7373,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5415,96 +7462,229 @@ constructor( class NewSubscriptionPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -5512,19 +7692,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5534,22 +7740,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5578,17 +7787,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } @@ -5596,9 +7821,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -5607,13 +7831,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -5630,13 +7861,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -5646,12 +7885,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -5666,11 +7912,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -5678,22 +7931,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -5710,22 +7972,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -5735,12 +8012,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -5749,11 +8034,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -5762,6 +8055,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5946,25 +8247,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5974,8 +8302,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -5987,7 +8315,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -5995,7 +8327,13 @@ constructor( * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { this.packageSize = packageSize } @@ -6059,22 +8397,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6084,8 +8446,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6099,10 +8461,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6223,22 +8592,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6248,8 +8641,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6264,10 +8657,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6397,6 +8797,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6478,96 +8886,229 @@ constructor( class NewSubscriptionMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -6575,19 +9116,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionMatrixPrice = apply { + if (!validated) { + cadence() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6597,22 +9164,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6641,27 +9211,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -6670,13 +9255,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -6693,13 +9285,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -6709,12 +9309,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -6729,11 +9336,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -6741,22 +9355,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -6773,22 +9396,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -6798,12 +9436,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -6812,11 +9458,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -6825,6 +9479,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6957,31 +9619,66 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ @JsonProperty("matrix_values") - fun matrixValues(): List = matrixValues + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6991,17 +9688,17 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -7009,29 +9706,61 @@ constructor( * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { matrixValues = - (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -7064,11 +9793,11 @@ constructor( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -7078,28 +9807,55 @@ constructor( @JsonCreator private constructor( @JsonProperty("dimension_values") - private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7109,14 +9865,15 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() @@ -7127,8 +9884,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -7138,13 +9903,23 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { - add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -7175,7 +9950,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -7279,22 +10054,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7304,8 +10103,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -7319,10 +10118,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7443,22 +10249,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7468,8 +10298,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -7484,10 +10314,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7617,6 +10454,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7698,96 +10543,229 @@ constructor( class NewSubscriptionTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -7795,19 +10773,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7817,22 +10821,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7861,17 +10868,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } @@ -7879,9 +10902,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -7890,13 +10912,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -7913,13 +10942,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -7929,12 +10966,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -7949,11 +10993,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -7961,22 +11012,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -7993,22 +11053,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -8018,12 +11093,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -8032,11 +11115,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -8045,6 +11136,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8229,18 +11328,34 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8250,26 +11365,42 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** * Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for rating based on total usage quantities into the specified tier + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -8297,7 +11428,7 @@ constructor( fun build(): TieredConfig = TieredConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -8306,30 +11437,64 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Exclusive tier ending value. If null, this is treated as the last tier + */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** * Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8339,9 +11504,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8354,10 +11519,19 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -8365,7 +11539,8 @@ constructor( * Exclusive tier ending value. If null, this is treated as the last * tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = + lastUnit(JsonField.ofNullable(lastUnit)) /** * Exclusive tier ending value. If null, this is treated as the last @@ -8383,6 +11558,14 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** + * Exclusive tier ending value. If null, this is treated as the last + * tier + */ + fun lastUnit(lastUnit: JsonField) = apply { + this.lastUnit = lastUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8462,22 +11645,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8487,8 +11694,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -8502,10 +11709,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8626,22 +11840,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8651,8 +11889,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -8667,10 +11905,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8800,6 +12045,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8881,97 +12134,230 @@ constructor( class NewSubscriptionTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_bps_config") - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -8979,19 +12365,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredBpsPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9001,22 +12413,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9046,17 +12461,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } @@ -9064,9 +12495,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -9075,13 +12505,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -9098,13 +12535,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -9114,12 +12559,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -9134,11 +12586,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -9146,22 +12605,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -9178,22 +12646,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -9203,12 +12686,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -9217,11 +12708,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -9230,6 +12729,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9414,7 +12921,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -9423,12 +12932,29 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9438,13 +12964,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -9453,14 +12979,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -9488,7 +13031,7 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -9497,33 +13040,71 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Inclusive tier starting value */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9533,10 +13114,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9550,31 +13131,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9653,22 +13249,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9678,8 +13298,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -9693,10 +13313,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9817,22 +13444,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9842,8 +13493,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -9858,10 +13509,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9991,6 +13649,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10072,96 +13738,229 @@ constructor( class NewSubscriptionBpsPrice @JsonCreator private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -10169,19 +13968,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10191,22 +14016,25 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10233,26 +14061,42 @@ constructor( newSubscriptionBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -10261,13 +14105,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -10284,13 +14135,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -10300,12 +14159,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -10320,11 +14186,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -10332,22 +14205,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -10364,22 +14246,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -10389,12 +14286,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -10403,11 +14308,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -10416,6 +14329,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10464,23 +14385,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10490,8 +14433,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10503,17 +14446,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10704,22 +14654,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10729,8 +14703,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -10744,10 +14718,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10868,22 +14849,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10893,8 +14898,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -10909,10 +14914,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11042,6 +15054,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11123,96 +15143,229 @@ constructor( class NewSubscriptionBulkBpsPrice @JsonCreator private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -11220,19 +15373,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11242,22 +15421,25 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11285,28 +15467,43 @@ constructor( newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -11315,13 +15512,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -11338,13 +15542,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -11354,12 +15566,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -11374,11 +15593,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -11386,22 +15612,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -11418,22 +15653,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -11443,12 +15693,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -11457,11 +15715,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -11470,6 +15736,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -11520,7 +15794,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -11529,12 +15805,29 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single + * tier based on total volume + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11544,13 +15837,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -11558,14 +15851,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a + * single tier based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -11593,7 +15903,7 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -11602,29 +15912,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11634,9 +15974,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11649,26 +15989,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11878,22 +16229,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11903,8 +16278,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -11918,10 +16293,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12042,22 +16424,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12067,8 +16473,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -12083,10 +16489,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12216,6 +16629,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12297,96 +16718,229 @@ constructor( class NewSubscriptionBulkPrice @JsonCreator private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -12394,19 +16948,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12416,22 +16996,25 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12458,26 +17041,42 @@ constructor( newSubscriptionBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -12486,13 +17085,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -12509,13 +17115,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -12525,12 +17139,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -12545,11 +17166,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -12557,22 +17185,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -12589,22 +17226,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -12614,12 +17266,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -12628,11 +17288,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -12641,6 +17309,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -12689,18 +17365,34 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12710,22 +17402,36 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -12753,7 +17459,7 @@ constructor( fun build(): BulkConfig = BulkConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -12762,24 +17468,48 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12789,8 +17519,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12802,14 +17532,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits - } + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = @@ -12822,6 +17555,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13032,22 +17770,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13057,8 +17819,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -13072,10 +17834,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13196,22 +17965,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13221,8 +18014,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -13237,10 +18030,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13370,6 +18170,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13451,42 +18259,166 @@ constructor( class NewSubscriptionThresholdTotalAmountPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("threshold_total_amount_config") fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = thresholdTotalAmountConfig /** @@ -13494,56 +18426,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -13551,19 +18492,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13573,22 +18540,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13623,27 +18594,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig( thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -13652,13 +18639,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -13675,13 +18669,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -13691,12 +18693,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -13711,11 +18720,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -13723,22 +18739,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -13755,22 +18780,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -13780,12 +18820,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -13794,11 +18842,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -13807,6 +18863,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13999,6 +19063,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14070,22 +19142,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14095,8 +19191,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14110,10 +19206,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14234,22 +19337,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14259,8 +19386,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14275,10 +19402,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14408,6 +19542,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14489,98 +19631,230 @@ constructor( class NewSubscriptionTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") - private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -14588,19 +19862,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14610,22 +19910,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14655,27 +19958,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -14684,13 +20003,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -14707,13 +20033,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -14723,12 +20057,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -14743,11 +20084,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -14755,22 +20103,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -14787,22 +20144,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -14812,12 +20184,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -14826,11 +20206,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -14839,6 +20227,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15031,6 +20427,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15101,22 +20505,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15126,8 +20554,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -15141,10 +20569,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15265,22 +20700,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15290,8 +20749,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -15306,10 +20765,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15439,6 +20905,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15520,98 +20994,232 @@ constructor( class NewSubscriptionTieredWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -15619,19 +21227,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15641,22 +21275,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15690,28 +21327,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -15720,13 +21371,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -15743,13 +21401,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -15759,12 +21425,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -15779,11 +21452,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -15791,22 +21471,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -15823,22 +21512,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -15848,12 +21552,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -15862,11 +21574,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -15875,6 +21595,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16067,6 +21795,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16138,22 +21874,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16163,8 +21923,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -16178,10 +21938,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16302,22 +22069,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16327,8 +22118,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -16343,10 +22134,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16476,6 +22274,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16557,98 +22363,232 @@ constructor( class NewSubscriptionUnitWithPercentPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -16656,19 +22596,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16678,22 +22644,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16724,28 +22693,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -16754,13 +22737,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -16777,13 +22767,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -16793,12 +22791,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -16813,11 +22818,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -16825,22 +22837,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -16857,22 +22878,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -16882,12 +22918,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -16896,11 +22940,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -16909,6 +22961,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -17101,6 +23161,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17171,22 +23239,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17196,8 +23288,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -17211,10 +23303,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17335,22 +23434,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17360,8 +23483,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -17376,10 +23499,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17509,6 +23639,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17590,42 +23728,166 @@ constructor( class NewSubscriptionPackageWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_with_allocation_config") fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = packageWithAllocationConfig /** @@ -17633,56 +23895,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -17690,19 +23961,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17712,22 +24009,27 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17763,27 +24065,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -17792,13 +24110,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -17815,13 +24140,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -17831,12 +24164,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -17851,11 +24191,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -17863,22 +24210,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -17895,22 +24251,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -17920,12 +24291,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -17934,11 +24313,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -17947,6 +24334,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -18139,6 +24534,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18211,22 +24614,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18236,8 +24663,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -18251,10 +24678,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18375,22 +24809,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18400,8 +24858,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -18416,10 +24874,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18549,6 +25014,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18630,42 +25103,166 @@ constructor( class NewSubscriptionTierWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_with_proration_config") fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = tieredWithProrationConfig /** @@ -18673,56 +25270,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -18730,19 +25336,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTierWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18752,22 +25384,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18801,27 +25437,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig( tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -18830,13 +25482,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -18853,13 +25512,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -18869,12 +25536,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -18889,11 +25563,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -18901,22 +25582,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -18933,22 +25623,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -18958,12 +25663,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -18972,11 +25685,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -18985,6 +25706,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19177,6 +25906,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19248,22 +25985,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19273,8 +26034,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -19288,10 +26049,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19412,22 +26180,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19437,8 +26229,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -19453,10 +26245,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19586,6 +26385,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19667,98 +26474,232 @@ constructor( class NewSubscriptionUnitWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -19766,19 +26707,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19788,22 +26755,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19837,28 +26807,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -19867,13 +26851,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -19890,13 +26881,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -19906,12 +26905,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -19926,11 +26932,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -19938,22 +26951,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -19970,22 +26992,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -19995,12 +27032,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -20009,11 +27054,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -20022,6 +27075,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -20214,6 +27275,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20285,22 +27354,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20310,8 +27403,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -20325,10 +27418,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20449,22 +27549,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20474,8 +27598,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -20490,10 +27614,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20623,6 +27754,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20704,98 +27843,232 @@ constructor( class NewSubscriptionGroupedAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -20803,19 +28076,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + if (!validated) { + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20825,22 +28124,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20874,28 +28176,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -20904,13 +28220,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -20927,13 +28250,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -20943,12 +28274,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -20963,11 +28301,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -20975,22 +28320,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -21007,22 +28361,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -21032,12 +28401,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -21046,11 +28423,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -21059,6 +28444,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21199,6 +28592,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21322,22 +28723,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21347,8 +28772,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -21362,10 +28787,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21486,22 +28918,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21511,8 +28967,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -21527,10 +28983,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21660,6 +29123,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21741,99 +29212,235 @@ constructor( class NewSubscriptionGroupedWithProratedMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") - @JsonProperty("grouped_with_prorated_minimum_config") fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -21841,19 +29448,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21863,24 +29496,27 @@ constructor( class Builder { - private var cadence: Cadence? = null + private var cadence: JsonField? = null private var groupedWithProratedMinimumConfig: - GroupedWithProratedMinimumConfig? = + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21921,29 +29557,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -21952,13 +29608,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -21975,13 +29638,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -21991,12 +29662,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -22011,11 +29689,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -22023,22 +29708,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -22055,22 +29749,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -22080,12 +29789,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -22094,11 +29811,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -22107,6 +29832,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22247,6 +29980,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22372,22 +30113,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22397,8 +30162,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -22412,10 +30177,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22536,22 +30308,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22561,8 +30357,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -22577,10 +30373,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22710,6 +30513,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22792,97 +30603,231 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -22890,19 +30835,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22912,22 +30883,25 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22961,28 +30935,42 @@ constructor( } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -22991,13 +30979,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -23014,13 +31009,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -23030,12 +31033,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -23050,11 +31060,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -23062,22 +31079,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -23094,22 +31120,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -23119,12 +31160,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -23133,11 +31182,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -23146,6 +31203,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23204,6 +31269,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23409,22 +31482,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23434,8 +31531,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -23449,10 +31546,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23573,22 +31677,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23598,8 +31726,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -23614,10 +31742,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23747,6 +31882,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23847,9 +31990,11 @@ constructor( class BillingCycleAnchorConfiguration @JsonCreator private constructor( - @JsonProperty("day") private val day: Long, - @JsonProperty("month") private val month: Long?, - @JsonProperty("year") private val year: Long?, + @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), + @JsonProperty("month") + @ExcludeMissing + private val month: JsonField = JsonMissing.of(), + @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -23860,24 +32005,55 @@ constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") fun day(): Long = day + fun day(): Long = day.getRequired("day") + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(): Optional = Optional.ofNullable(month.getNullable("month")) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on + * 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(): Optional = Optional.ofNullable(year.getNullable("year")) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") fun month(): Optional = Optional.ofNullable(month) + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") fun year(): Optional = Optional.ofNullable(year) + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23887,9 +32063,9 @@ constructor( class Builder { - private var day: Long? = null - private var month: Long? = null - private var year: Long? = null + private var day: JsonField? = null + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23908,13 +32084,21 @@ constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - fun day(day: Long) = apply { this.day = day } + fun day(day: Long) = day(JsonField.of(day)) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun day(day: JsonField) = apply { this.day = day } /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long?) = apply { this.month = month } + fun month(month: Long?) = month(JsonField.ofNullable(month)) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -23929,11 +32113,17 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun month(month: Optional) = month(month.orElse(null) as Long?) + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: JsonField) = apply { this.month = month } + /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long?) = apply { this.year = year } + fun year(year: Long?) = year(JsonField.ofNullable(year)) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -23948,6 +32138,12 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun year(year: Optional) = year(year.orElse(null) as Long?) + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: JsonField) = apply { this.year = year } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24074,6 +32270,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24133,18 +32337,34 @@ constructor( class RemoveAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment_id") private val adjustmentId: String, + @JsonProperty("adjustment_id") + @ExcludeMissing + private val adjustmentId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the adjustment to remove on the subscription. */ - @JsonProperty("adjustment_id") fun adjustmentId(): String = adjustmentId + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** The id of the adjustment to remove on the subscription. */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (!validated) { + adjustmentId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24154,7 +32374,7 @@ constructor( class Builder { - private var adjustmentId: String? = null + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24164,7 +32384,12 @@ constructor( } /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = apply { this.adjustmentId = adjustmentId } + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24214,23 +32439,45 @@ constructor( class RemovePrice @JsonCreator private constructor( - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("price_id") private val priceId: String?, + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** The id of the price to remove on the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + /** The external price id of the price to remove on the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** The id of the price to remove on the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (!validated) { + externalPriceId() + priceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24240,8 +32487,8 @@ constructor( class Builder { - private var externalPriceId: String? = null - private var priceId: String? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24252,20 +32499,27 @@ constructor( } /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to remove on the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to remove on the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24315,23 +32569,47 @@ constructor( class ReplaceAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment") private val adjustment: Adjustment, - @JsonProperty("replaces_adjustment_id") private val replacesAdjustmentId: String, + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + private val replacesAdjustmentId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") fun adjustment(): Adjustment = adjustment + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The id of the adjustment on the plan to replace in the subscription. */ @JsonProperty("replaces_adjustment_id") - fun replacesAdjustmentId(): String = replacesAdjustmentId + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (!validated) { + adjustment() + replacesAdjustmentId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24341,8 +32619,8 @@ constructor( class Builder { - private var adjustment: Adjustment? = null - private var replacesAdjustmentId: String? = null + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24353,30 +32631,34 @@ constructor( } /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = apply { this.adjustment = adjustment } + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = apply { - this.adjustment = Adjustment.ofNewPercentageDiscount(newPercentageDiscount) + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment } - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = apply { - this.adjustment = Adjustment.ofNewUsageDiscount(newUsageDiscount) - } + fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = + adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = apply { - this.adjustment = Adjustment.ofNewAmountDiscount(newAmountDiscount) - } + fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = + adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - fun adjustment(newMinimum: Adjustment.NewMinimum) = apply { - this.adjustment = Adjustment.ofNewMinimum(newMinimum) - } + fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = + adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - fun adjustment(newMaximum: Adjustment.NewMaximum) = apply { - this.adjustment = Adjustment.ofNewMaximum(newMaximum) - } + fun adjustment(newMinimum: Adjustment.NewMinimum) = + adjustment(Adjustment.ofNewMinimum(newMinimum)) + + fun adjustment(newMaximum: Adjustment.NewMaximum) = + adjustment(Adjustment.ofNewMaximum(newMaximum)) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = apply { + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { this.replacesAdjustmentId = replacesAdjustmentId } @@ -24422,6 +32704,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newPercentageDiscount(): Optional = Optional.ofNullable(newPercentageDiscount) @@ -24472,6 +32756,26 @@ constructor( } } + fun validate(): Adjustment = apply { + if (!validated) { + if ( + newPercentageDiscount == null && + newUsageDiscount == null && + newAmountDiscount == null && + newMinimum == null && + newMaximum == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + newPercentageDiscount?.validate() + newUsageDiscount?.validate() + newAmountDiscount?.validate() + newMinimum?.validate() + newMaximum?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24541,29 +32845,40 @@ constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newPercentageDiscount = it, _json = json) + } } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newUsageDiscount = it, _json = json) + } } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newAmountDiscount = it, _json = json) + } } "minimum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMinimum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMinimum = it, _json = json) + } } "maximum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMaximum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMaximum = it, _json = json) + } } } @@ -24597,35 +32912,75 @@ constructor( class NewPercentageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPercentageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + percentageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24635,47 +32990,58 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var percentageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var percentageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = newPercentageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } percentageDiscount = newPercentageDiscount.percentageDiscount isInvoiceLevel = newPercentageDiscount.isInvoiceLevel additionalProperties = newPercentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun percentageDiscount(percentageDiscount: Double) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount } /** @@ -24683,15 +33049,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24723,7 +33089,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(percentageDiscount) { "`percentageDiscount` is required but was not set" }, @@ -24806,34 +33172,74 @@ constructor( class NewUsageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("usage_discount") private val usageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("usage_discount") fun usageDiscount(): Double = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewUsageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + usageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24843,46 +33249,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var usageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var usageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newUsageDiscount: NewUsageDiscount) = apply { adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = newUsageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } usageDiscount = newUsageDiscount.usageDiscount isInvoiceLevel = newUsageDiscount.isInvoiceLevel additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun usageDiscount(usageDiscount: Double) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount } /** @@ -24890,15 +33307,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24930,7 +33347,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(usageDiscount) { "`usageDiscount` is required but was not set" }, @@ -25013,34 +33430,74 @@ constructor( class NewAmountDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("amount_discount") private val amountDiscount: String, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType - @JsonProperty("amount_discount") fun amountDiscount(): String = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAmountDiscount = apply { + if (!validated) { + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25050,46 +33507,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var amountDiscount: String? = null - private var appliesToPriceIds: MutableList? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newAmountDiscount: NewAmountDiscount) = apply { adjustmentType = newAmountDiscount.adjustmentType amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = newAmountDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = newAmountDiscount.isInvoiceLevel additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } - fun amountDiscount(amountDiscount: String) = apply { + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -25097,15 +33565,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -25140,7 +33608,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, isInvoiceLevel, additionalProperties.toImmutable(), ) @@ -25220,38 +33688,84 @@ constructor( class NewMinimum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMinimum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + itemId() + minimumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25261,51 +33775,64 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var itemId: String? = null - private var minimumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMinimum: NewMinimum) = apply { adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } itemId = newMinimum.itemId minimumAmount = newMinimum.minimumAmount isInvoiceLevel = newMinimum.isInvoiceLevel additionalProperties = newMinimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun minimumAmount(minimumAmount: String) = apply { - this.minimumAmount = minimumAmount - } + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** @@ -25313,15 +33840,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -25353,7 +33880,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" @@ -25437,34 +33964,74 @@ constructor( class NewMaximum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("maximum_amount") private val maximumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("maximum_amount") fun maximumAmount(): String = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMaximum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + maximumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25474,46 +34041,56 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var maximumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMaximum: NewMaximum) = apply { adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = newMaximum.maximumAmount isInvoiceLevel = newMaximum.isInvoiceLevel additionalProperties = newMaximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun maximumAmount(maximumAmount: String) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** @@ -25521,15 +34098,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -25561,7 +34138,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, @@ -25663,60 +34240,137 @@ constructor( class ReplacePrice @JsonCreator private constructor( - @JsonProperty("replaces_price_id") private val replacesPriceId: String, - @JsonProperty("discounts") private val discounts: List?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("minimum_amount") private val minimumAmount: String?, - @JsonProperty("price") private val price: Price?, - @JsonProperty("price_id") private val priceId: String?, + @JsonProperty("replaces_price_id") + @ExcludeMissing + private val replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the price on the plan to replace in the subscription. */ - @JsonProperty("replaces_price_id") fun replacesPriceId(): String = replacesPriceId + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** The id of the price on the plan to replace in the subscription. */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the * replacement price. */ @JsonProperty("discounts") - fun discounts(): Optional> = Optional.ofNullable(discounts) + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** The external price id of the price to add to the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** The new quantity of the price, if the price is a fixed price. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the * replacement price. */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. */ @JsonProperty("minimum_amount") - fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount) + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") fun price(): Optional = Optional.ofNullable(price) + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (!validated) { + replacesPriceId() + discounts().map { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price() + priceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25726,20 +34380,20 @@ constructor( class Builder { - private var replacesPriceId: String? = null - private var discounts: MutableList? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var maximumAmount: String? = null - private var minimumAmount: String? = null - private var price: Price? = null - private var priceId: String? = null + private var replacesPriceId: JsonField? = null + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(replacePrice: ReplacePrice) = apply { replacesPriceId = replacePrice.replacesPriceId - discounts = replacePrice.discounts?.toMutableList() + discounts = replacePrice.discounts.map { it.toMutableList() } externalPriceId = replacePrice.externalPriceId fixedPriceQuantity = replacePrice.fixedPriceQuantity maximumAmount = replacePrice.maximumAmount @@ -25750,7 +34404,11 @@ constructor( } /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = apply { + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { this.replacesPriceId = replacesPriceId } @@ -25758,9 +34416,7 @@ constructor( * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the * replacement price. */ - fun discounts(discounts: List?) = apply { - this.discounts = discounts?.toMutableList() - } + fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the @@ -25768,28 +34424,48 @@ constructor( */ fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the * replacement price. */ fun addDiscount(discount: Discount) = apply { - discounts = (discounts ?: mutableListOf()).apply { add(discount) } + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to add to the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The new quantity of the price, if the price is a fixed price. */ fun fixedPriceQuantity(fixedPriceQuantity: Double) = fixedPriceQuantity(fixedPriceQuantity as Double?) @@ -25799,11 +34475,17 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the * replacement price. */ - fun maximumAmount(maximumAmount: String?) = apply { this.maximumAmount = maximumAmount } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the @@ -25812,11 +34494,20 @@ constructor( fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. */ - fun minimumAmount(minimumAmount: String?) = apply { this.minimumAmount = minimumAmount } + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the @@ -25825,138 +34516,141 @@ constructor( fun minimumAmount(minimumAmount: Optional) = minimumAmount(minimumAmount.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = apply { this.price = price } + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** The definition of a new price to create and add to the subscription. */ fun price(price: Optional) = price(price.orElse(null)) - fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = apply { - this.price = Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice) - } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } - fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = apply { - this.price = Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice) - } + fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = + price(Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice)) - fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = apply { - this.price = Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice) - } + fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = + price(Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice)) - fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = apply { - this.price = Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice) - } + fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = + price(Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice)) - fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = apply { - this.price = Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice) - } + fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = + price(Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice)) - fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice) - } + fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = + price(Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice)) - fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice) - } + fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = + price(Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice)) - fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = apply { - this.price = Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice) - } + fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = + price(Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice)) + + fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = + price(Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice)) fun price( newSubscriptionThresholdTotalAmountPrice: Price.NewSubscriptionThresholdTotalAmountPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionThresholdTotalAmountPrice( newSubscriptionThresholdTotalAmountPrice ) - } + ) fun price(newSubscriptionTieredPackagePrice: Price.NewSubscriptionTieredPackagePrice) = - apply { - this.price = - Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice) - } + price(Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice)) fun price( newSubscriptionTieredWithMinimumPrice: Price.NewSubscriptionTieredWithMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTieredWithMinimumPrice( newSubscriptionTieredWithMinimumPrice ) - } + ) fun price( newSubscriptionUnitWithPercentPrice: Price.NewSubscriptionUnitWithPercentPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithPercentPrice(newSubscriptionUnitWithPercentPrice) - } + ) fun price( newSubscriptionPackageWithAllocationPrice: Price.NewSubscriptionPackageWithAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionPackageWithAllocationPrice( newSubscriptionPackageWithAllocationPrice ) - } + ) fun price( newSubscriptionTierWithProrationPrice: Price.NewSubscriptionTierWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTierWithProrationPrice( newSubscriptionTierWithProrationPrice ) - } + ) fun price( newSubscriptionUnitWithProrationPrice: Price.NewSubscriptionUnitWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithProrationPrice( newSubscriptionUnitWithProrationPrice ) - } + ) fun price( newSubscriptionGroupedAllocationPrice: Price.NewSubscriptionGroupedAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedAllocationPrice( newSubscriptionGroupedAllocationPrice ) - } + ) fun price( newSubscriptionGroupedWithProratedMinimumPrice: Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedWithProratedMinimumPrice( newSubscriptionGroupedWithProratedMinimumPrice ) - } + ) fun price( newSubscriptionBulkWithProrationPrice: Price.NewSubscriptionBulkWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionBulkWithProrationPrice( newSubscriptionBulkWithProrationPrice ) - } + ) /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to add to the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to add to the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -25981,7 +34675,7 @@ constructor( checkNotNull(replacesPriceId) { "`replacesPriceId` is required but was not set" }, - discounts?.toImmutable(), + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, externalPriceId, fixedPriceQuantity, maximumAmount, @@ -25996,37 +34690,81 @@ constructor( class Discount @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("amount_discount") private val amountDiscount: String?, - @JsonProperty("percentage_discount") private val percentageDiscount: Double?, - @JsonProperty("usage_discount") private val usageDiscount: Double?, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount.getNullable("amount_discount")) + + /** + * Only available if discount_type is `percentage`. This is a number between 0 and 1. + */ + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + fun usageDiscount(): Optional = + Optional.ofNullable(usageDiscount.getNullable("usage_discount")) + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** Only available if discount_type is `amount`. */ @JsonProperty("amount_discount") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** * Only available if discount_type is `percentage`. This is a number between 0 and 1. */ @JsonProperty("percentage_discount") - fun percentageDiscount(): Optional = Optional.ofNullable(percentageDiscount) + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ @JsonProperty("usage_discount") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Discount = apply { + if (!validated) { + discountType() + amountDiscount() + percentageDiscount() + usageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -26036,10 +34774,10 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var amountDiscount: String? = null - private var percentageDiscount: Double? = null - private var usageDiscount: Double? = null + private var discountType: JsonField? = null + private var amountDiscount: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26051,26 +34789,32 @@ constructor( additionalProperties = discount.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = apply { - this.amountDiscount = amountDiscount - } + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) /** Only available if discount_type is `amount`. */ fun amountDiscount(amountDiscount: Optional) = amountDiscount(amountDiscount.orElse(null)) + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + /** * Only available if discount_type is `percentage`. This is a number between 0 * and 1. */ - fun percentageDiscount(percentageDiscount: Double?) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double?) = + percentageDiscount(JsonField.ofNullable(percentageDiscount)) /** * Only available if discount_type is `percentage`. This is a number between 0 @@ -26087,13 +34831,20 @@ constructor( fun percentageDiscount(percentageDiscount: Optional) = percentageDiscount(percentageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + /** * Only available if discount_type is `usage`. Number of usage units that this * discount is for */ - fun usageDiscount(usageDiscount: Double?) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double?) = + usageDiscount(JsonField.ofNullable(usageDiscount)) /** * Only available if discount_type is `usage`. Number of usage units that this @@ -26109,6 +34860,14 @@ constructor( fun usageDiscount(usageDiscount: Optional) = usageDiscount(usageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -26266,6 +35025,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newSubscriptionUnitPrice(): Optional = Optional.ofNullable(newSubscriptionUnitPrice) @@ -26514,6 +35275,52 @@ constructor( } } + fun validate(): Price = apply { + if (!validated) { + if ( + newSubscriptionUnitPrice == null && + newSubscriptionPackagePrice == null && + newSubscriptionMatrixPrice == null && + newSubscriptionTieredPrice == null && + newSubscriptionTieredBpsPrice == null && + newSubscriptionBpsPrice == null && + newSubscriptionBulkBpsPrice == null && + newSubscriptionBulkPrice == null && + newSubscriptionThresholdTotalAmountPrice == null && + newSubscriptionTieredPackagePrice == null && + newSubscriptionTieredWithMinimumPrice == null && + newSubscriptionUnitWithPercentPrice == null && + newSubscriptionPackageWithAllocationPrice == null && + newSubscriptionTierWithProrationPrice == null && + newSubscriptionUnitWithProrationPrice == null && + newSubscriptionGroupedAllocationPrice == null && + newSubscriptionGroupedWithProratedMinimumPrice == null && + newSubscriptionBulkWithProrationPrice == null + ) { + throw OrbInvalidDataException("Unknown Price: $_json") + } + newSubscriptionUnitPrice?.validate() + newSubscriptionPackagePrice?.validate() + newSubscriptionMatrixPrice?.validate() + newSubscriptionTieredPrice?.validate() + newSubscriptionTieredBpsPrice?.validate() + newSubscriptionBpsPrice?.validate() + newSubscriptionBulkBpsPrice?.validate() + newSubscriptionBulkPrice?.validate() + newSubscriptionThresholdTotalAmountPrice?.validate() + newSubscriptionTieredPackagePrice?.validate() + newSubscriptionTieredWithMinimumPrice?.validate() + newSubscriptionUnitWithPercentPrice?.validate() + newSubscriptionPackageWithAllocationPrice?.validate() + newSubscriptionTierWithProrationPrice?.validate() + newSubscriptionUnitWithProrationPrice?.validate() + newSubscriptionGroupedAllocationPrice?.validate() + newSubscriptionGroupedWithProratedMinimumPrice?.validate() + newSubscriptionBulkWithProrationPrice?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26782,55 +35589,76 @@ constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionUnitPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionUnitPrice = it, _json = json) + } } "package" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionPackagePrice = it, _json = json) } } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionMatrixPrice = it, _json = json) } } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredPrice = it, _json = json) } } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredBpsPrice = it, _json = json) } } "bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBpsPrice = it, _json = json) + } } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionBulkBpsPrice = it, _json = json) } } "bulk" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBulkPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBulkPrice = it, _json = json) + } } "threshold_total_amount" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionThresholdTotalAmountPrice = it, @@ -26842,7 +35670,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredPackagePrice = it, @@ -26854,7 +35684,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredWithMinimumPrice = it, @@ -26866,7 +35698,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithPercentPrice = it, @@ -26878,7 +35712,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionPackageWithAllocationPrice = it, @@ -26890,7 +35726,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTierWithProrationPrice = it, @@ -26902,7 +35740,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithProrationPrice = it, @@ -26914,7 +35754,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedAllocationPrice = it, @@ -26926,7 +35768,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedWithProratedMinimumPrice = it, @@ -26938,7 +35782,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionBulkWithProrationPrice = it, @@ -27008,96 +35854,229 @@ constructor( class NewSubscriptionUnitPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -27105,19 +36084,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27127,22 +36132,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27170,25 +36178,41 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -27197,13 +36221,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -27220,13 +36251,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -27236,12 +36275,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -27256,11 +36302,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -27268,22 +36321,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -27300,22 +36362,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -27325,12 +36402,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -27339,11 +36424,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -27352,6 +36445,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -27534,18 +36635,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27555,7 +36672,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27566,7 +36683,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -27625,22 +36747,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27650,8 +36796,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27665,10 +36811,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -27789,22 +36942,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27814,8 +36991,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27830,10 +37007,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -27963,6 +37147,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28044,96 +37236,229 @@ constructor( class NewSubscriptionPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -28141,19 +37466,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28163,22 +37514,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -28207,17 +37561,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } @@ -28225,9 +37595,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -28236,13 +37605,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -28259,13 +37635,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -28275,12 +37659,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -28295,11 +37686,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -28307,22 +37705,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -28339,22 +37746,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -28364,12 +37786,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -28378,11 +37808,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -28391,6 +37829,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -28575,25 +38021,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28603,8 +38076,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -28616,7 +38089,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -28624,7 +38101,13 @@ constructor( * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { this.packageSize = packageSize } @@ -28688,22 +38171,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28713,8 +38220,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -28728,10 +38235,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -28852,22 +38366,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28877,8 +38415,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -28893,10 +38431,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -29026,6 +38571,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29107,96 +38660,229 @@ constructor( class NewSubscriptionMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -29204,19 +38890,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionMatrixPrice = apply { + if (!validated) { + cadence() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29226,22 +38938,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29270,27 +38985,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -29299,13 +39029,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -29322,13 +39059,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -29338,12 +39083,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -29358,11 +39110,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -29370,22 +39129,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -29402,22 +39170,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -29427,12 +39210,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -29441,11 +39232,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -29454,6 +39253,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -29586,31 +39393,66 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ @JsonProperty("matrix_values") - fun matrixValues(): List = matrixValues + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29620,17 +39462,17 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -29638,29 +39480,61 @@ constructor( * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { matrixValues = - (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -29693,11 +39567,11 @@ constructor( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -29707,28 +39581,55 @@ constructor( @JsonCreator private constructor( @JsonProperty("dimension_values") - private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29738,14 +39639,15 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() @@ -29756,8 +39658,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -29767,13 +39677,23 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { - add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -29804,7 +39724,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -29908,22 +39828,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29933,8 +39877,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -29948,10 +39892,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -30072,22 +40023,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30097,8 +40072,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -30113,10 +40088,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -30246,6 +40228,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30327,96 +40317,229 @@ constructor( class NewSubscriptionTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -30424,19 +40547,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30446,22 +40595,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -30490,17 +40642,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } @@ -30508,9 +40676,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -30519,13 +40686,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -30542,13 +40716,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -30558,12 +40740,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -30578,11 +40767,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -30590,22 +40786,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -30622,22 +40827,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -30647,12 +40867,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -30661,11 +40889,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -30674,6 +40910,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -30858,18 +41102,34 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30879,26 +41139,42 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** * Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for rating based on total usage quantities into the specified tier + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -30926,7 +41202,7 @@ constructor( fun build(): TieredConfig = TieredConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -30935,30 +41211,64 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Exclusive tier ending value. If null, this is treated as the last tier + */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** * Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30968,9 +41278,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -30983,10 +41293,19 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -30994,7 +41313,8 @@ constructor( * Exclusive tier ending value. If null, this is treated as the last * tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = + lastUnit(JsonField.ofNullable(lastUnit)) /** * Exclusive tier ending value. If null, this is treated as the last @@ -31012,6 +41332,14 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** + * Exclusive tier ending value. If null, this is treated as the last + * tier + */ + fun lastUnit(lastUnit: JsonField) = apply { + this.lastUnit = lastUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -31091,22 +41419,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31116,8 +41468,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -31131,10 +41483,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -31255,22 +41614,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31280,8 +41663,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -31296,10 +41679,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -31429,6 +41819,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31510,97 +41908,230 @@ constructor( class NewSubscriptionTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_bps_config") - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -31608,19 +42139,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredBpsPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31630,22 +42187,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31675,17 +42235,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } @@ -31693,9 +42269,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -31704,13 +42279,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -31727,13 +42309,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -31743,12 +42333,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -31763,11 +42360,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -31775,22 +42379,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -31807,22 +42420,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -31832,12 +42460,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -31846,11 +42482,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -31859,6 +42503,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -32043,7 +42695,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -32052,12 +42706,29 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32067,13 +42738,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -32082,14 +42753,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -32117,7 +42805,7 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -32126,33 +42814,71 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps + + /** Inclusive tier starting value */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32162,10 +42888,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -32179,31 +42905,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -32282,22 +43023,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32307,8 +43072,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -32322,10 +43087,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -32446,22 +43218,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32471,8 +43267,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -32487,10 +43283,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -32620,6 +43423,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32701,96 +43512,229 @@ constructor( class NewSubscriptionBpsPrice @JsonCreator private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -32798,19 +43742,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32820,22 +43790,25 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -32862,26 +43835,42 @@ constructor( newSubscriptionBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -32890,13 +43879,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -32913,13 +43909,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -32929,12 +43933,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -32949,11 +43960,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -32961,22 +43979,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -32993,22 +44020,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -33018,12 +44060,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -33032,11 +44082,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -33045,6 +44103,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -33093,23 +44159,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33119,8 +44207,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -33132,17 +44220,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -33333,22 +44428,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33358,8 +44477,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -33373,10 +44492,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -33497,22 +44623,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33522,8 +44672,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -33538,10 +44688,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -33671,6 +44828,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33752,96 +44917,229 @@ constructor( class NewSubscriptionBulkBpsPrice @JsonCreator private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -33849,19 +45147,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33871,22 +45195,25 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33914,28 +45241,43 @@ constructor( newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -33944,13 +45286,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -33967,13 +45316,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -33983,12 +45340,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -34003,11 +45367,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -34015,22 +45386,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -34047,22 +45427,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -34072,12 +45467,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -34086,11 +45489,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -34099,6 +45510,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -34149,7 +45568,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -34158,12 +45579,29 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single + * tier based on total volume + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34173,13 +45611,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -34187,14 +45625,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a + * single tier based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -34222,7 +45677,7 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -34231,29 +45686,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34263,9 +45748,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -34278,26 +45763,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -34507,22 +46003,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34532,8 +46052,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -34547,10 +46067,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -34671,22 +46198,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34696,8 +46247,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -34712,10 +46263,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -34845,6 +46403,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34926,96 +46492,229 @@ constructor( class NewSubscriptionBulkPrice @JsonCreator private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -35023,19 +46722,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35045,22 +46770,25 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35087,26 +46815,42 @@ constructor( newSubscriptionBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -35115,13 +46859,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -35138,13 +46889,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -35154,12 +46913,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -35174,11 +46940,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -35186,22 +46959,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -35218,22 +47000,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -35243,12 +47040,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -35257,11 +47062,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -35270,6 +47083,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -35318,18 +47139,34 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35339,22 +47176,36 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -35382,7 +47233,7 @@ constructor( fun build(): BulkConfig = BulkConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -35391,24 +47242,48 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35418,8 +47293,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -35431,14 +47306,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits - } + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = @@ -35451,6 +47329,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -35661,22 +47544,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35686,8 +47593,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -35701,10 +47608,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -35825,22 +47739,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35850,8 +47788,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -35866,10 +47804,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -35999,6 +47944,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36080,42 +48033,166 @@ constructor( class NewSubscriptionThresholdTotalAmountPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("threshold_total_amount_config") fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = thresholdTotalAmountConfig /** @@ -36123,56 +48200,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -36180,19 +48266,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36202,22 +48314,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -36252,27 +48368,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig( thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -36281,13 +48413,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -36304,13 +48443,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -36320,12 +48467,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -36340,11 +48494,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -36352,22 +48513,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -36384,22 +48554,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -36409,12 +48594,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -36423,11 +48616,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -36436,6 +48637,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -36628,6 +48837,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36699,22 +48916,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36724,8 +48965,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -36739,10 +48980,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -36863,22 +49111,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36888,8 +49160,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -36904,10 +49176,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -37037,6 +49316,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37118,98 +49405,230 @@ constructor( class NewSubscriptionTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") - private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -37217,19 +49636,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37239,22 +49684,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37284,27 +49732,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -37313,13 +49777,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -37336,13 +49807,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -37352,12 +49831,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -37372,11 +49858,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -37384,22 +49877,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -37416,22 +49918,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -37441,12 +49958,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -37455,11 +49980,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -37468,6 +50001,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -37660,6 +50201,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37730,22 +50279,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37755,8 +50328,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -37770,10 +50343,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -37894,22 +50474,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37919,8 +50523,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -37935,10 +50539,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -38068,6 +50679,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38149,98 +50768,232 @@ constructor( class NewSubscriptionTieredWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -38248,19 +51001,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38270,22 +51049,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -38319,28 +51101,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -38349,13 +51145,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -38372,13 +51175,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -38388,12 +51199,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -38408,11 +51226,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -38420,22 +51245,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -38452,22 +51286,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -38477,12 +51326,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -38491,11 +51348,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -38504,6 +51369,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -38696,6 +51569,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38767,22 +51648,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38792,8 +51697,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -38807,10 +51712,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -38931,22 +51843,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38956,8 +51892,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -38972,10 +51908,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -39105,6 +52048,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39186,98 +52137,232 @@ constructor( class NewSubscriptionUnitWithPercentPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -39285,19 +52370,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39307,22 +52418,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -39353,28 +52467,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -39383,13 +52511,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -39406,13 +52541,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -39422,12 +52565,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -39442,11 +52592,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -39454,22 +52611,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -39486,22 +52652,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -39511,12 +52692,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -39525,11 +52714,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -39538,6 +52735,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -39730,6 +52935,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39800,22 +53013,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39825,8 +53062,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -39840,10 +53077,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -39964,22 +53208,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39989,8 +53257,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -40005,10 +53273,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -40138,6 +53413,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40219,42 +53502,166 @@ constructor( class NewSubscriptionPackageWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_with_allocation_config") fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = packageWithAllocationConfig /** @@ -40262,56 +53669,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -40319,19 +53735,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40341,22 +53783,27 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40392,27 +53839,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -40421,13 +53884,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -40444,13 +53914,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -40460,12 +53938,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -40480,11 +53965,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -40492,22 +53984,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -40524,22 +54025,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -40549,12 +54065,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -40563,11 +54087,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -40576,6 +54108,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -40768,6 +54308,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40840,22 +54388,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40865,8 +54437,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -40880,10 +54452,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -41004,22 +54583,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41029,8 +54632,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -41045,10 +54648,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -41178,6 +54788,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41259,42 +54877,166 @@ constructor( class NewSubscriptionTierWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_with_proration_config") fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = tieredWithProrationConfig /** @@ -41302,56 +55044,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -41359,19 +55110,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTierWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41381,22 +55158,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -41430,27 +55211,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig( tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -41459,13 +55256,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -41482,13 +55286,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -41498,12 +55310,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -41518,11 +55337,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -41530,22 +55356,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -41562,22 +55397,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -41587,12 +55437,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -41601,11 +55459,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -41614,6 +55480,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -41806,6 +55680,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41877,22 +55759,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41902,8 +55808,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -41917,10 +55823,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -42041,22 +55954,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42066,8 +56003,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -42082,10 +56019,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -42215,6 +56159,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42296,98 +56248,232 @@ constructor( class NewSubscriptionUnitWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -42395,19 +56481,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42417,22 +56529,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42466,28 +56581,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -42496,13 +56625,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -42519,13 +56655,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -42535,12 +56679,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -42555,11 +56706,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -42567,22 +56725,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -42599,22 +56766,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -42624,12 +56806,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -42638,11 +56828,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -42651,6 +56849,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -42843,6 +57049,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42914,22 +57128,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42939,8 +57177,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -42954,10 +57192,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -43078,22 +57323,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43103,8 +57372,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -43119,10 +57388,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -43252,6 +57528,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43333,98 +57617,232 @@ constructor( class NewSubscriptionGroupedAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -43432,19 +57850,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + if (!validated) { + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43454,22 +57898,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -43503,28 +57950,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -43533,13 +57994,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -43556,13 +58024,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -43572,12 +58048,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -43592,11 +58075,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -43604,22 +58094,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -43636,22 +58135,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -43661,12 +58175,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -43675,11 +58197,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -43688,6 +58218,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -43828,6 +58366,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43951,22 +58497,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43976,8 +58546,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -43991,10 +58561,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -44115,22 +58692,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44140,8 +58741,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -44156,10 +58757,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -44289,6 +58897,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44370,99 +58986,235 @@ constructor( class NewSubscriptionGroupedWithProratedMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") - @JsonProperty("grouped_with_prorated_minimum_config") fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -44470,19 +59222,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44492,24 +59270,27 @@ constructor( class Builder { - private var cadence: Cadence? = null + private var cadence: JsonField? = null private var groupedWithProratedMinimumConfig: - GroupedWithProratedMinimumConfig? = + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44550,29 +59331,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -44581,13 +59382,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -44604,13 +59412,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -44620,12 +59436,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -44640,11 +59463,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -44652,22 +59482,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -44684,22 +59523,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -44709,12 +59563,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -44723,11 +59585,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -44736,6 +59606,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -44876,6 +59754,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45001,22 +59887,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45026,8 +59936,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -45041,10 +59951,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -45165,22 +60082,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45190,8 +60131,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -45206,10 +60147,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -45339,6 +60287,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45421,97 +60377,231 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -45519,19 +60609,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45541,22 +60657,25 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -45590,28 +60709,42 @@ constructor( } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -45620,13 +60753,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -45643,13 +60783,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -45659,12 +60807,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -45679,11 +60834,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -45691,22 +60853,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -45723,22 +60894,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -45748,12 +60934,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -45762,11 +60956,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -45775,6 +60977,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -45833,6 +61043,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -46038,22 +61256,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -46063,8 +61305,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -46078,10 +61320,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -46202,22 +61451,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -46227,8 +61500,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -46243,10 +61516,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -46376,6 +61656,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt index 9172a8a2..76faccfb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionCreateResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,40 +439,41 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscriptionCreateResponse: SubscriptionCreateResponse) = apply { id = subscriptionCreateResponse.id activePlanPhaseOrder = subscriptionCreateResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionCreateResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionCreateResponse.adjustmentIntervals.map { it.toMutableList() } autoCollection = subscriptionCreateResponse.autoCollection billingCycleAnchorConfiguration = subscriptionCreateResponse.billingCycleAnchorConfiguration @@ -462,16 +483,20 @@ private constructor( currentBillingPeriodStartDate = subscriptionCreateResponse.currentBillingPeriodStartDate customer = subscriptionCreateResponse.customer defaultInvoiceMemo = subscriptionCreateResponse.defaultInvoiceMemo - discountIntervals = subscriptionCreateResponse.discountIntervals + discountIntervals = + subscriptionCreateResponse.discountIntervals.map { it.toMutableList() } endDate = subscriptionCreateResponse.endDate - fixedFeeQuantitySchedule = subscriptionCreateResponse.fixedFeeQuantitySchedule + fixedFeeQuantitySchedule = + subscriptionCreateResponse.fixedFeeQuantitySchedule.map { it.toMutableList() } invoicingThreshold = subscriptionCreateResponse.invoicingThreshold - maximumIntervals = subscriptionCreateResponse.maximumIntervals + maximumIntervals = + subscriptionCreateResponse.maximumIntervals.map { it.toMutableList() } metadata = subscriptionCreateResponse.metadata - minimumIntervals = subscriptionCreateResponse.minimumIntervals + minimumIntervals = + subscriptionCreateResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionCreateResponse.netTerms plan = subscriptionCreateResponse.plan - priceIntervals = subscriptionCreateResponse.priceIntervals + priceIntervals = subscriptionCreateResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionCreateResponse.redeemedCoupon startDate = subscriptionCreateResponse.startDate status = subscriptionCreateResponse.status @@ -483,9 +508,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -498,15 +532,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -552,8 +617,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -570,8 +643,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -626,8 +707,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -643,11 +731,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -657,10 +762,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -672,7 +796,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -695,7 +833,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -734,11 +886,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -779,31 +948,55 @@ private constructor( fun build(): SubscriptionCreateResponse = SubscriptionCreateResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -844,20 +1037,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -885,18 +1084,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -912,6 +1112,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -919,11 +1134,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -957,11 +1190,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1264,11 +1500,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1276,12 +1512,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1289,15 +1525,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1327,13 +1563,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1341,7 +1577,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1381,7 +1618,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1399,9 +1650,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1409,7 +1669,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1438,13 +1701,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1576,16 +1850,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1593,7 +1867,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1601,15 +1875,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1639,13 +1913,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1653,7 +1927,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1679,7 +1956,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1712,9 +2003,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1722,7 +2022,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1751,13 +2054,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1888,16 +2202,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1905,21 +2219,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1949,20 +2265,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1988,7 +2305,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2006,9 +2337,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2016,7 +2356,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2060,13 +2403,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2203,16 +2557,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2220,24 +2574,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2268,21 +2624,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2308,7 +2665,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2347,9 +2718,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2357,7 +2737,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2386,14 +2769,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2524,16 +2918,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2541,21 +2935,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2585,20 +2981,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2623,7 +3020,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2656,9 +3067,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2666,7 +3086,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2695,13 +3118,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2834,19 +3268,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2872,7 +3306,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2907,7 +3341,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2919,7 +3366,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2948,7 +3408,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3200,25 +3660,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3247,19 +3715,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3282,7 +3752,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3292,9 +3776,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3303,7 +3802,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3340,12 +3842,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3468,25 +3978,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3515,18 +4031,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3541,7 +4061,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3551,9 +4085,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3562,7 +4111,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3612,12 +4164,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3743,26 +4303,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3791,18 +4359,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3816,7 +4386,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3826,9 +4410,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3837,7 +4436,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3889,12 +4491,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -3998,13 +4608,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4031,10 +4645,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4046,7 +4660,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4085,10 +4701,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4158,24 +4774,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4203,17 +4825,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4226,7 +4849,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4236,11 +4873,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4288,11 +4943,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4442,24 +5103,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4487,17 +5154,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4510,7 +5178,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4520,11 +5202,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4572,11 +5272,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4911,10 +5617,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4923,7 +5631,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4932,13 +5640,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4946,7 +5657,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5176,13 +5888,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5213,15 +5927,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5231,7 +5946,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5255,8 +5971,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5272,8 +5996,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5288,7 +6021,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5301,8 +6040,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5310,7 +6057,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5772,6 +6541,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5807,14 +6641,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5842,11 +6685,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5872,9 +6717,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5925,9 +6770,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5992,11 +6839,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6022,9 +6873,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6039,7 +6890,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6070,9 +6923,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6172,7 +7025,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6196,7 +7051,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6205,7 +7060,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6228,7 +7085,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt index 0b39fcbf..bd9c0c11 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsParams.kt @@ -14,6 +14,17 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint is used to fetch a day-by-day snapshot of a subscription's costs in Orb, calculated + * by applying pricing information to the underlying usage (see the + * [subscription usage endpoint](fetch-subscription-usage) to fetch usage per metric, in usage units + * rather than a currency). + * + * The semantics of this endpoint exactly mirror those of + * [fetching a customer's costs](fetch-customer-costs). Use this endpoint to limit your analysis of + * costs to a specific subscription for the customer (e.g. to de-aggregate costs when a customer's + * subscription has started and stopped on the same day). + */ class SubscriptionFetchCostsParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt index 0c968d8a..bb8364a1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchCostsResponse.kt @@ -29,7 +29,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -53,19 +53,34 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscriptionFetchCostsResponse: SubscriptionFetchCostsResponse) = apply { - data = subscriptionFetchCostsResponse.data + data = subscriptionFetchCostsResponse.data.map { it.toMutableList() } additionalProperties = subscriptionFetchCostsResponse.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -88,7 +103,8 @@ private constructor( fun build(): SubscriptionFetchCostsResponse = SubscriptionFetchCostsResponse( - data.map { it.toImmutable() }, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -128,17 +144,23 @@ private constructor( /** Total costs for the timeframe, including any minimums and discounts. */ fun total(): String = total.getRequired("total") - @JsonProperty("per_price_costs") @ExcludeMissing fun _perPriceCosts() = perPriceCosts + @JsonProperty("per_price_costs") + @ExcludeMissing + fun _perPriceCosts(): JsonField> = perPriceCosts /** Total costs for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd - @JsonProperty("timeframe_start") @ExcludeMissing fun _timeframeStart() = timeframeStart + @JsonProperty("timeframe_start") + @ExcludeMissing + fun _timeframeStart(): JsonField = timeframeStart /** Total costs for the timeframe, including any minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total @JsonAnyGetter @ExcludeMissing @@ -166,16 +188,16 @@ private constructor( class Builder { - private var perPriceCosts: JsonField> = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() + private var perPriceCosts: JsonField>? = null + private var subtotal: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null + private var total: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { - perPriceCosts = data.perPriceCosts + perPriceCosts = data.perPriceCosts.map { it.toMutableList() } subtotal = data.subtotal timeframeEnd = data.timeframeEnd timeframeStart = data.timeframeStart @@ -187,7 +209,20 @@ private constructor( perPriceCosts(JsonField.of(perPriceCosts)) fun perPriceCosts(perPriceCosts: JsonField>) = apply { - this.perPriceCosts = perPriceCosts + this.perPriceCosts = perPriceCosts.map { it.toMutableList() } + } + + fun addPerPriceCost(perPriceCost: PerPriceCost) = apply { + perPriceCosts = + (perPriceCosts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(perPriceCost) + } } /** Total costs for the timeframe, excluding any minimums and discounts. */ @@ -237,11 +272,12 @@ private constructor( fun build(): Data = Data( - perPriceCosts.map { it.toImmutable() }, - subtotal, - timeframeEnd, - timeframeStart, - total, + checkNotNull(perPriceCosts) { "`perPriceCosts` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(timeframeEnd) { "`timeframeEnd` is required but was not set" }, + checkNotNull(timeframeStart) { "`timeframeStart` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -733,16 +769,16 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** Price's contributions for the timeframe, excluding any minimums and discounts. */ - @JsonProperty("subtotal") @ExcludeMissing fun _subtotal() = subtotal + @JsonProperty("subtotal") @ExcludeMissing fun _subtotal(): JsonField = subtotal /** Price's contributions for the timeframe, including minimums and discounts. */ - @JsonProperty("total") @ExcludeMissing fun _total() = total + @JsonProperty("total") @ExcludeMissing fun _total(): JsonField = total /** The price's quantity for the timeframe */ - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -769,9 +805,9 @@ private constructor( class Builder { - private var price: JsonField = JsonMissing.of() - private var subtotal: JsonField = JsonMissing.of() - private var total: JsonField = JsonMissing.of() + private var price: JsonField? = null + private var subtotal: JsonField? = null + private var total: JsonField? = null private var quantity: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -1252,6 +1288,73 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = + price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = + price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * Price's contributions for the timeframe, excluding any minimums and discounts. */ @@ -1269,7 +1372,15 @@ private constructor( fun total(total: JsonField) = apply { this.total = total } /** The price's quantity for the timeframe */ - fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) + fun quantity(quantity: Double?) = quantity(JsonField.ofNullable(quantity)) + + /** The price's quantity for the timeframe */ + fun quantity(quantity: Double) = quantity(quantity as Double?) + + /** The price's quantity for the timeframe */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun quantity(quantity: Optional) = + quantity(quantity.orElse(null) as Double?) /** The price's quantity for the timeframe */ fun quantity(quantity: JsonField) = apply { this.quantity = quantity } @@ -1298,9 +1409,9 @@ private constructor( fun build(): PerPriceCost = PerPriceCost( - price, - subtotal, - total, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(subtotal) { "`subtotal` is required but was not set" }, + checkNotNull(total) { "`total` is required but was not set" }, quantity, additionalProperties.toImmutable(), ) diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt index 05cd1a6a..4799e9c1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchParams.kt @@ -7,6 +7,10 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint is used to fetch a [Subscription](../guides/concepts#subscription) given an + * identifier. + */ class SubscriptionFetchParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt index 5e4efdc6..59b587a1 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleParams.kt @@ -10,6 +10,11 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns a [paginated](../reference/pagination) list of all plans associated with a + * subscription along with their start and end dates. This list contains the subscription's initial + * plan along with past and future plan changes. + */ class SubscriptionFetchScheduleParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt index 5cf15f0d..2b331445 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchScheduleResponse.kt @@ -42,13 +42,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -75,10 +79,10 @@ private constructor( class Builder { - private var createdAt: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var createdAt: JsonField? = null + private var endDate: JsonField? = null + private var plan: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -96,7 +100,9 @@ private constructor( fun createdAt(createdAt: JsonField) = apply { this.createdAt = createdAt } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -129,10 +135,10 @@ private constructor( fun build(): SubscriptionFetchScheduleResponse = SubscriptionFetchScheduleResponse( - createdAt, - endDate, - plan, - startDate, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -164,16 +170,18 @@ private constructor( fun name(): Optional = Optional.ofNullable(name.getNullable("name")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** * An optional user-defined ID for this plan resource, used throughout the system as an * alias for this Plan. Use this field to identify a plan by an existing identifier in your * system. */ - @JsonProperty("external_plan_id") @ExcludeMissing fun _externalPlanId() = externalPlanId + @JsonProperty("external_plan_id") + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -199,9 +207,9 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var externalPlanId: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var externalPlanId: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -212,7 +220,9 @@ private constructor( additionalProperties = plan.additionalProperties.toMutableMap() } - fun id(id: String) = id(JsonField.of(id)) + fun id(id: String?) = id(JsonField.ofNullable(id)) + + fun id(id: Optional) = id(id.orElse(null)) fun id(id: JsonField) = apply { this.id = id } @@ -221,8 +231,16 @@ private constructor( * alias for this Plan. Use this field to identify a plan by an existing identifier in * your system. */ - fun externalPlanId(externalPlanId: String) = - externalPlanId(JsonField.of(externalPlanId)) + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) + + /** + * An optional user-defined ID for this plan resource, used throughout the system as an + * alias for this Plan. Use this field to identify a plan by an existing identifier in + * your system. + */ + fun externalPlanId(externalPlanId: Optional) = + externalPlanId(externalPlanId.orElse(null)) /** * An optional user-defined ID for this plan resource, used throughout the system as an @@ -233,7 +251,9 @@ private constructor( this.externalPlanId = externalPlanId } - fun name(name: String) = name(JsonField.of(name)) + fun name(name: String?) = name(JsonField.ofNullable(name)) + + fun name(name: Optional) = name(name.orElse(null)) fun name(name: JsonField) = apply { this.name = name } @@ -258,9 +278,9 @@ private constructor( fun build(): Plan = Plan( - id, - externalPlanId, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(externalPlanId) { "`externalPlanId` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt index dca1593f..edc34f62 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionFetchUsageParams.kt @@ -14,6 +14,182 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint is used to fetch a subscription's usage in Orb. Especially when combined with + * optional query parameters, this endpoint is a powerful way to build visualizations on top of + * Orb's event data and metrics. + * + * With no query parameters specified, this endpoint returns usage for the subscription's _current + * billing period_ across each billable metric that participates in the subscription. Usage + * quantities returned are the result of evaluating the metric definition for the entirety of the + * customer's billing period. + * + * ### Default response shape + * + * Orb returns a `data` array with an object corresponding to each billable metric. Nested within + * this object is a `usage` array which has a `quantity` value and a corresponding `timeframe_start` + * and `timeframe_end`. The `quantity` value represents the calculated usage value for the billable + * metric over the specified timeframe (inclusive of the `timeframe_start` timestamp and exclusive + * of the `timeframe_end` timestamp). + * + * Orb will include _every_ window in the response starting from the beginning of the billing + * period, even when there were no events (and therefore no usage) in the window. This increases the + * size of the response but prevents the caller from filling in gaps and handling cumbersome + * time-based logic. + * + * The query parameters in this endpoint serve to override this behavior and provide some key + * functionality, as listed below. Note that this functionality can also be used _in conjunction_ + * with each other, e.g. to display grouped usage on a custom timeframe. + * + * ## Custom timeframe + * + * In order to view usage for a custom timeframe rather than the current billing period, specify a + * `timeframe_start` and `timeframe_end`. This will calculate quantities for usage incurred between + * timeframe_start (inclusive) and timeframe_end (exclusive), i.e. `[timeframe_start, + * timeframe_end)`. + * + * Note: + * - These timestamps must be specified in ISO 8601 format and UTC timezone, e.g. + * `2022-02-01T05:00:00Z`. + * - Both parameters must be specified if either is specified. + * + * ## Grouping by custom attributes + * + * In order to view a single metric grouped by a specific _attribute_ that each event is tagged with + * (e.g. `cluster`), you must additionally specify a `billable_metric_id` and a `group_by` key. The + * `group_by` key denotes the event property on which to group. + * + * When returning grouped usage, only usage for `billable_metric_id` is returned, and a separate + * object in the `data` array is returned for each value of the `group_by` key present in your + * events. The `quantity` value is the result of evaluating the billable metric for events filtered + * to a single value of the `group_by` key. + * + * Orb expects that events that match the billable metric will contain values in the `properties` + * dictionary that correspond to the `group_by` key specified. By default, Orb will not return a + * `null` group (i.e. events that match the metric but do not have the key set). Currently, it is + * only possible to view usage grouped by a single attribute at a time. + * + * When viewing grouped usage, Orb uses pagination to limit the response size to 1000 groups by + * default. If there are more groups for a given subscription, pagination metadata in the response + * can be used to fetch all of the data. + * + * The following example shows usage for an "API Requests" billable metric grouped by `region`. Note + * the extra `metric_group` dictionary in the response, which provides metadata about the group: + * ```json + * { + * "data": [ + * { + * "usage": [ + * { + * "quantity": 0.19291, + * "timeframe_start": "2021-10-01T07:00:00Z", + * "timeframe_end": "2021-10-02T07:00:00Z", + * }, + * ... + * ], + * "metric_group": { + * "property_key": "region", + * "property_value": "asia/pacific" + * }, + * "billable_metric": { + * "id": "Fe9pbpMk86xpwdGB", + * "name": "API Requests" + * }, + * "view_mode": "periodic" + * }, + * ... + * ] + * } + * ``` + * + * ## Windowed usage + * + * The `granularity` parameter can be used to _window_ the usage `quantity` value into periods. When + * not specified, usage is returned for the entirety of the time range. + * + * When `granularity = day` is specified with a timeframe longer than a day, Orb will return a + * `quantity` value for each full day between `timeframe_start` and `timeframe_end`. Note that the + * days are demarcated by the _customer's local midnight_. + * + * For example, with `timeframe_start = 2022-02-01T05:00:00Z`, `timeframe_end = + * 2022-02-04T01:00:00Z` and `granularity=day`, the following windows will be returned for a + * customer in the `America/Los_Angeles` timezone since local midnight is `08:00` UTC: + * - `[2022-02-01T05:00:00Z, 2022-02-01T08:00:00Z)` + * - `[2022-02-01T08:00:00, 2022-02-02T08:00:00Z)` + * - `[2022-02-02T08:00:00, 2022-02-03T08:00:00Z)` + * - `[2022-02-03T08:00:00, 2022-02-04T01:00:00Z)` + * + * ```json + * { + * "data": [ + * { + * "billable_metric": { + * "id": "Q8w89wjTtBdejXKsm", + * "name": "API Requests" + * }, + * "usage": [ + * { + * "quantity": 0, + * "timeframe_end": "2022-02-01T08:00:00+00:00", + * "timeframe_start": "2022-02-01T05:00:00+00:00" + * }, + * { + * + * "quantity": 0, + * "timeframe_end": "2022-02-02T08:00:00+00:00", + * "timeframe_start": "2022-02-01T08:00:00+00:00" + * }, + * { + * "quantity": 0, + * "timeframe_end": "2022-02-03T08:00:00+00:00", + * "timeframe_start": "2022-02-02T08:00:00+00:00" + * }, + * { + * "quantity": 0, + * "timeframe_end": "2022-02-04T01:00:00+00:00", + * "timeframe_start": "2022-02-03T08:00:00+00:00" + * } + * ], + * "view_mode": "periodic" + * }, + * ... + * ] + * } + * ``` + * + * ## Decomposable vs. non-decomposable metrics + * + * Billable metrics fall into one of two categories: decomposable and non-decomposable. A + * decomposable billable metric, such as a sum or a count, can be displayed and aggregated across + * arbitrary timescales. On the other hand, a non-decomposable metric is not meaningful when only a + * slice of the billing window is considered. + * + * As an example, if we have a billable metric that's defined to count unique users, displaying a + * graph of unique users for each day is not representative of the billable metric value over the + * month (days could have an overlapping set of 'unique' users). Instead, what's useful for any + * given day is the number of unique users in the billing period so far, which are the _cumulative_ + * unique users. + * + * Accordingly, this endpoint returns treats these two types of metrics differently when `group_by` + * is specified: + * - Decomposable metrics can be grouped by any event property. + * - Non-decomposable metrics can only be grouped by the corresponding price's invoice grouping key. + * If no invoice grouping key is present, the metric does not support `group_by`. + * + * ## Matrix prices + * + * When a billable metric is attached to a price that uses matrix pricing, it's important to view + * usage grouped by those matrix dimensions. In this case, use the query parameters + * `first_dimension_key`, `first_dimension_value` and `second_dimension_key`, + * `second_dimension_value` while filtering to a specific `billable_metric_id`. + * + * For example, if your compute metric has a separate unit price (i.e. a matrix pricing model) per + * `region` and `provider`, your request might provide the following parameters: + * - `first_dimension_key`: `region` + * - `first_dimension_value`: `us-east-1` + * - `second_dimension_key`: `provider` + * - `second_dimension_value`: `aws` + */ class SubscriptionFetchUsageParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt index 5ae61ad5..cdf0f4a4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionListParams.kt @@ -15,6 +15,16 @@ import java.time.format.DateTimeFormatter import java.util.Objects import java.util.Optional +/** + * This endpoint returns a list of all subscriptions for an account as a + * [paginated](../reference/pagination) list, ordered starting from the most recently created + * subscription. For a full discussion of the subscription resource, see + * [Subscription](../guides/concepts#subscription). + * + * Subscriptions can be filtered for a specific customer by using either the customer_id or + * external_customer_id query parameters. To filter subscriptions for multiple customers, use the + * customer_id[] or external_customer_id[] query parameters. + */ class SubscriptionListParams constructor( private val createdAtGt: OffsetDateTime?, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt index 6bc09978..1b90a79b 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -31,6 +32,71 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint is used to add and edit subscription + * [price intervals](../reference/price-interval). By making modifications to a subscription’s price + * intervals, you can + * [flexibly and atomically control the billing behavior of a subscription](../guides/product-catalog/modifying-subscriptions). + * + * ## Adding price intervals + * + * Prices can be added as price intervals to a subscription by specifying them in the `add` array. A + * `price_id` or `external_price_id` from an add-on price or previously removed plan price can be + * specified to reuse an existing price definition (however, please note that prices from other + * plans cannot be added to the subscription). Additionally, a new price can be specified using the + * `price` field — this price will be created automatically. + * + * A `start_date` must be specified for the price interval. This is the date when the price will + * start billing on the subscription, so this will notably result in an immediate charge at this + * time for any billed in advance fixed fees. The `end_date` will default to null, resulting in a + * price interval that will bill on a continually recurring basis. Both of these dates can be set in + * the past or the future and Orb will generate or modify invoices to ensure the subscription’s + * invoicing behavior is correct. + * + * Additionally, a discount, minimum, or maximum can be specified on the price interval. This will + * only apply to this price interval, not any other price intervals on the subscription. + * + * ## Adjustment intervals + * + * An adjustment interval represents the time period that a particular adjustment (a discount, + * minimum, or maximum) applies to the prices on a subscription. Adjustment intervals can be added + * to a subscription by specifying them in the `add_adjustments` array, or modified via the + * `edit_adjustments` array. When creating an adjustment interval, you'll need to provide the + * definition of the new adjustment (the type of adjustment, and which prices it applies to), as + * well as the start and end dates for the adjustment interval. The start and end dates of an + * existing adjustment interval can be edited via the `edit_adjustments` field (just like price + * intervals). (To "change" the amount of a discount, minimum, or maximum, then, you'll need to end + * the existing interval, and create a new adjustment interval with the new amount and a start date + * that matches the end date of the previous interval.) + * + * ## Editing price intervals + * + * Price intervals can be adjusted by specifying edits to make in the `edit` array. A + * `price_interval_id` to edit must be specified — this can be retrieved from the `price_intervals` + * field on the subscription. + * + * A new `start_date` or `end_date` can be specified to change the range of the price interval, + * which will modify past or future invoices to ensure correctness. If either of these dates are + * unspecified, they will default to the existing date on the price interval. To remove a price + * interval entirely from a subscription, set the `end_date` to be equivalent to the `start_date`. + * + * ## Fixed fee quantity transitions + * + * The fixed fee quantity transitions for a fixed fee price interval can also be specified when + * adding or editing by passing an array for `fixed_fee_quantity_transitions`. A fixed fee quantity + * transition must have a `quantity` and an `effective_date`, which is the date after which the new + * quantity will be used for billing. If a fixed fee quantity transition is scheduled at a billing + * period boundary, the full quantity will be billed on an invoice with the other prices on the + * subscription. If the fixed fee quantity transition is scheduled mid-billing period, the + * difference between the existing quantity and quantity specified in the transition will be + * prorated for the rest of the billing period and billed immediately, which will generate a new + * invoice. + * + * Notably, the list of fixed fee quantity transitions passed will overwrite the existing fixed fee + * quantity transitions on the price interval, so the entire list of transitions must be specified + * to add additional transitions. The existing list of transitions can be retrieved using the + * `fixed_fee_quantity_transitions` property on a subscription’s serialized price intervals. + */ class SubscriptionPriceIntervalsParams constructor( private val subscriptionId: String, @@ -53,12 +119,24 @@ constructor( /** A list of adjustments to edit on the subscription. */ fun editAdjustments(): Optional> = body.editAdjustments() - fun _additionalHeaders(): Headers = additionalHeaders + /** A list of price intervals to add to the subscription. */ + fun _add(): JsonField> = body._add() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** A list of adjustments to add to the subscription. */ + fun _addAdjustments(): JsonField> = body._addAdjustments() + + /** A list of price intervals to edit on the subscription. */ + fun _edit(): JsonField> = body._edit() + + /** A list of adjustments to edit on the subscription. */ + fun _editAdjustments(): JsonField> = body._editAdjustments() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionPriceIntervalsBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -76,32 +154,68 @@ constructor( class SubscriptionPriceIntervalsBody @JsonCreator internal constructor( - @JsonProperty("add") private val add: List?, - @JsonProperty("add_adjustments") private val addAdjustments: List?, - @JsonProperty("edit") private val edit: List?, - @JsonProperty("edit_adjustments") private val editAdjustments: List?, + @JsonProperty("add") + @ExcludeMissing + private val add: JsonField> = JsonMissing.of(), + @JsonProperty("add_adjustments") + @ExcludeMissing + private val addAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("edit") + @ExcludeMissing + private val edit: JsonField> = JsonMissing.of(), + @JsonProperty("edit_adjustments") + @ExcludeMissing + private val editAdjustments: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A list of price intervals to add to the subscription. */ - @JsonProperty("add") fun add(): Optional> = Optional.ofNullable(add) + fun add(): Optional> = Optional.ofNullable(add.getNullable("add")) + + /** A list of adjustments to add to the subscription. */ + fun addAdjustments(): Optional> = + Optional.ofNullable(addAdjustments.getNullable("add_adjustments")) + + /** A list of price intervals to edit on the subscription. */ + fun edit(): Optional> = Optional.ofNullable(edit.getNullable("edit")) + + /** A list of adjustments to edit on the subscription. */ + fun editAdjustments(): Optional> = + Optional.ofNullable(editAdjustments.getNullable("edit_adjustments")) + + /** A list of price intervals to add to the subscription. */ + @JsonProperty("add") @ExcludeMissing fun _add(): JsonField> = add /** A list of adjustments to add to the subscription. */ @JsonProperty("add_adjustments") - fun addAdjustments(): Optional> = Optional.ofNullable(addAdjustments) + @ExcludeMissing + fun _addAdjustments(): JsonField> = addAdjustments /** A list of price intervals to edit on the subscription. */ - @JsonProperty("edit") fun edit(): Optional> = Optional.ofNullable(edit) + @JsonProperty("edit") @ExcludeMissing fun _edit(): JsonField> = edit /** A list of adjustments to edit on the subscription. */ @JsonProperty("edit_adjustments") - fun editAdjustments(): Optional> = Optional.ofNullable(editAdjustments) + @ExcludeMissing + fun _editAdjustments(): JsonField> = editAdjustments @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionPriceIntervalsBody = apply { + if (!validated) { + add().map { it.forEach { it.validate() } } + addAdjustments().map { it.forEach { it.validate() } } + edit().map { it.forEach { it.validate() } } + editAdjustments().map { it.forEach { it.validate() } } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -111,72 +225,111 @@ constructor( class Builder { - private var add: MutableList? = null - private var addAdjustments: MutableList? = null - private var edit: MutableList? = null - private var editAdjustments: MutableList? = null + private var add: JsonField>? = null + private var addAdjustments: JsonField>? = null + private var edit: JsonField>? = null + private var editAdjustments: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscriptionPriceIntervalsBody: SubscriptionPriceIntervalsBody) = apply { - add = subscriptionPriceIntervalsBody.add?.toMutableList() - addAdjustments = subscriptionPriceIntervalsBody.addAdjustments?.toMutableList() - edit = subscriptionPriceIntervalsBody.edit?.toMutableList() + add = subscriptionPriceIntervalsBody.add.map { it.toMutableList() } + addAdjustments = + subscriptionPriceIntervalsBody.addAdjustments.map { it.toMutableList() } + edit = subscriptionPriceIntervalsBody.edit.map { it.toMutableList() } editAdjustments = - subscriptionPriceIntervalsBody.editAdjustments?.toMutableList() + subscriptionPriceIntervalsBody.editAdjustments.map { it.toMutableList() } additionalProperties = subscriptionPriceIntervalsBody.additionalProperties.toMutableMap() } /** A list of price intervals to add to the subscription. */ - fun add(add: List?) = apply { this.add = add?.toMutableList() } + fun add(add: List) = add(JsonField.of(add)) /** A list of price intervals to add to the subscription. */ - fun add(add: Optional>) = add(add.orElse(null)) + fun add(add: JsonField>) = apply { this.add = add.map { it.toMutableList() } } /** A list of price intervals to add to the subscription. */ fun addAdd(add: Add) = apply { - this.add = (this.add ?: mutableListOf()).apply { add(add) } + this.add = + (this.add ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(add) + } } /** A list of adjustments to add to the subscription. */ - fun addAdjustments(addAdjustments: List?) = apply { - this.addAdjustments = addAdjustments?.toMutableList() - } + fun addAdjustments(addAdjustments: List) = + addAdjustments(JsonField.of(addAdjustments)) /** A list of adjustments to add to the subscription. */ - fun addAdjustments(addAdjustments: Optional>) = - addAdjustments(addAdjustments.orElse(null)) + fun addAdjustments(addAdjustments: JsonField>) = apply { + this.addAdjustments = addAdjustments.map { it.toMutableList() } + } /** A list of adjustments to add to the subscription. */ fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { - addAdjustments = (addAdjustments ?: mutableListOf()).apply { add(addAdjustment) } + addAdjustments = + (addAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addAdjustment) + } } /** A list of price intervals to edit on the subscription. */ - fun edit(edit: List?) = apply { this.edit = edit?.toMutableList() } + fun edit(edit: List) = edit(JsonField.of(edit)) /** A list of price intervals to edit on the subscription. */ - fun edit(edit: Optional>) = edit(edit.orElse(null)) + fun edit(edit: JsonField>) = apply { + this.edit = edit.map { it.toMutableList() } + } /** A list of price intervals to edit on the subscription. */ fun addEdit(edit: Edit) = apply { - this.edit = (this.edit ?: mutableListOf()).apply { add(edit) } + this.edit = + (this.edit ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(edit) + } } /** A list of adjustments to edit on the subscription. */ - fun editAdjustments(editAdjustments: List?) = apply { - this.editAdjustments = editAdjustments?.toMutableList() - } + fun editAdjustments(editAdjustments: List) = + editAdjustments(JsonField.of(editAdjustments)) /** A list of adjustments to edit on the subscription. */ - fun editAdjustments(editAdjustments: Optional>) = - editAdjustments(editAdjustments.orElse(null)) + fun editAdjustments(editAdjustments: JsonField>) = apply { + this.editAdjustments = editAdjustments.map { it.toMutableList() } + } /** A list of adjustments to edit on the subscription. */ fun addEditAdjustment(editAdjustment: EditAdjustment) = apply { - editAdjustments = (editAdjustments ?: mutableListOf()).apply { add(editAdjustment) } + editAdjustments = + (editAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(editAdjustment) + } } fun additionalProperties(additionalProperties: Map) = apply { @@ -200,10 +353,10 @@ constructor( fun build(): SubscriptionPriceIntervalsBody = SubscriptionPriceIntervalsBody( - add?.toImmutable(), - addAdjustments?.toImmutable(), - edit?.toImmutable(), - editAdjustments?.toImmutable(), + (add ?: JsonMissing.of()).map { it.toImmutable() }, + (addAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (edit ?: JsonMissing.of()).map { it.toImmutable() }, + (editAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -255,22 +408,23 @@ constructor( fun subscriptionId(subscriptionId: String) = apply { this.subscriptionId = subscriptionId } /** A list of price intervals to add to the subscription. */ - fun add(add: List?) = apply { body.add(add) } + fun add(add: List) = apply { body.add(add) } /** A list of price intervals to add to the subscription. */ - fun add(add: Optional>) = add(add.orElse(null)) + fun add(add: JsonField>) = apply { body.add(add) } /** A list of price intervals to add to the subscription. */ fun addAdd(add: Add) = apply { body.addAdd(add) } /** A list of adjustments to add to the subscription. */ - fun addAdjustments(addAdjustments: List?) = apply { + fun addAdjustments(addAdjustments: List) = apply { body.addAdjustments(addAdjustments) } /** A list of adjustments to add to the subscription. */ - fun addAdjustments(addAdjustments: Optional>) = - addAdjustments(addAdjustments.orElse(null)) + fun addAdjustments(addAdjustments: JsonField>) = apply { + body.addAdjustments(addAdjustments) + } /** A list of adjustments to add to the subscription. */ fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { @@ -278,28 +432,48 @@ constructor( } /** A list of price intervals to edit on the subscription. */ - fun edit(edit: List?) = apply { body.edit(edit) } + fun edit(edit: List) = apply { body.edit(edit) } /** A list of price intervals to edit on the subscription. */ - fun edit(edit: Optional>) = edit(edit.orElse(null)) + fun edit(edit: JsonField>) = apply { body.edit(edit) } /** A list of price intervals to edit on the subscription. */ fun addEdit(edit: Edit) = apply { body.addEdit(edit) } /** A list of adjustments to edit on the subscription. */ - fun editAdjustments(editAdjustments: List?) = apply { + fun editAdjustments(editAdjustments: List) = apply { body.editAdjustments(editAdjustments) } /** A list of adjustments to edit on the subscription. */ - fun editAdjustments(editAdjustments: Optional>) = - editAdjustments(editAdjustments.orElse(null)) + fun editAdjustments(editAdjustments: JsonField>) = apply { + body.editAdjustments(editAdjustments) + } /** A list of adjustments to edit on the subscription. */ fun addEditAdjustment(editAdjustment: EditAdjustment) = apply { body.addEditAdjustment(editAdjustment) } + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -398,25 +572,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionPriceIntervalsParams = SubscriptionPriceIntervalsParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, @@ -430,17 +585,37 @@ constructor( class Add @JsonCreator private constructor( - @JsonProperty("start_date") private val startDate: StartDate, - @JsonProperty("allocation_price") private val allocationPrice: AllocationPrice?, - @JsonProperty("discounts") private val discounts: List?, - @JsonProperty("end_date") private val endDate: EndDate?, - @JsonProperty("external_price_id") private val externalPriceId: String?, + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("allocation_price") + @ExcludeMissing + private val allocationPrice: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), @JsonProperty("fixed_fee_quantity_transitions") - private val fixedFeeQuantityTransitions: List?, - @JsonProperty("maximum_amount") private val maximumAmount: Double?, - @JsonProperty("minimum_amount") private val minimumAmount: Double?, - @JsonProperty("price") private val price: Price?, - @JsonProperty("price_id") private val priceId: String?, + @ExcludeMissing + private val fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -449,55 +624,131 @@ constructor( * The start date of the price interval. This is the date that the price will start billing * on the subscription. */ - @JsonProperty("start_date") fun startDate(): StartDate = startDate + fun startDate(): StartDate = startDate.getRequired("start_date") + + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(): Optional = + Optional.ofNullable(allocationPrice.getNullable("allocation_price")) + + /** A list of discounts to initialize on the price interval. */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** + * The end date of the price interval. This is the date that the price will stop billing on + * the subscription. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** A list of fixed fee quantity transitions to initialize on the price interval. */ + fun fixedFeeQuantityTransitions(): Optional> = + Optional.ofNullable( + fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") + ) + + /** + * The maximum amount that will be billed for this price interval for a given billing + * period. + */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * The minimum amount that will be billed for this price interval for a given billing + * period. + */ + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** + * The start date of the price interval. This is the date that the price will start billing + * on the subscription. + */ + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** The definition of a new allocation price to create and add to the subscription. */ @JsonProperty("allocation_price") - fun allocationPrice(): Optional = Optional.ofNullable(allocationPrice) + @ExcludeMissing + fun _allocationPrice(): JsonField = allocationPrice /** A list of discounts to initialize on the price interval. */ @JsonProperty("discounts") - fun discounts(): Optional> = Optional.ofNullable(discounts) + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** * The end date of the price interval. This is the date that the price will stop billing on * the subscription. */ - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** The external price id of the price to add to the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** A list of fixed fee quantity transitions to initialize on the price interval. */ @JsonProperty("fixed_fee_quantity_transitions") - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable(fixedFeeQuantityTransitions) + @ExcludeMissing + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The maximum amount that will be billed for this price interval for a given billing * period. */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * The minimum amount that will be billed for this price interval for a given billing * period. */ @JsonProperty("minimum_amount") - fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount) + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") fun price(): Optional = Optional.ofNullable(price) + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Add = apply { + if (!validated) { + startDate() + allocationPrice().map { it.validate() } + discounts() + endDate() + externalPriceId() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + maximumAmount() + minimumAmount() + price() + priceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -507,26 +758,29 @@ constructor( class Builder { - private var startDate: StartDate? = null - private var allocationPrice: AllocationPrice? = null - private var discounts: MutableList? = null - private var endDate: EndDate? = null - private var externalPriceId: String? = null - private var fixedFeeQuantityTransitions: MutableList? = null - private var maximumAmount: Double? = null - private var minimumAmount: Double? = null - private var price: Price? = null - private var priceId: String? = null + private var startDate: JsonField? = null + private var allocationPrice: JsonField = JsonMissing.of() + private var discounts: JsonField>? = null + private var endDate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(add: Add) = apply { startDate = add.startDate allocationPrice = add.allocationPrice - discounts = add.discounts?.toMutableList() + discounts = add.discounts.map { it.toMutableList() } endDate = add.endDate externalPriceId = add.externalPriceId - fixedFeeQuantityTransitions = add.fixedFeeQuantityTransitions?.toMutableList() + fixedFeeQuantityTransitions = + add.fixedFeeQuantityTransitions.map { it.toMutableList() } maximumAmount = add.maximumAmount minimumAmount = add.minimumAmount price = add.price @@ -538,43 +792,62 @@ constructor( * The start date of the price interval. This is the date that the price will start * billing on the subscription. */ - fun startDate(startDate: StartDate) = apply { this.startDate = startDate } + fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) - fun startDate(dateTime: OffsetDateTime) = apply { - this.startDate = StartDate.ofDateTime(dateTime) - } + /** + * The start date of the price interval. This is the date that the price will start + * billing on the subscription. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.startDate = StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) + + fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + startDate(StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) /** The definition of a new allocation price to create and add to the subscription. */ - fun allocationPrice(allocationPrice: AllocationPrice?) = apply { - this.allocationPrice = allocationPrice - } + fun allocationPrice(allocationPrice: AllocationPrice?) = + allocationPrice(JsonField.ofNullable(allocationPrice)) /** The definition of a new allocation price to create and add to the subscription. */ fun allocationPrice(allocationPrice: Optional) = allocationPrice(allocationPrice.orElse(null)) - /** A list of discounts to initialize on the price interval. */ - fun discounts(discounts: List?) = apply { - this.discounts = discounts?.toMutableList() + /** The definition of a new allocation price to create and add to the subscription. */ + fun allocationPrice(allocationPrice: JsonField) = apply { + this.allocationPrice = allocationPrice } + /** A list of discounts to initialize on the price interval. */ + fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) + /** A list of discounts to initialize on the price interval. */ fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) + /** A list of discounts to initialize on the price interval. */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + /** A list of discounts to initialize on the price interval. */ fun addDiscount(discount: Discount) = apply { - discounts = (discounts ?: mutableListOf()).apply { add(discount) } + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** * The end date of the price interval. This is the date that the price will stop billing * on the subscription. */ - fun endDate(endDate: EndDate?) = apply { this.endDate = endDate } + fun endDate(endDate: EndDate?) = endDate(JsonField.ofNullable(endDate)) /** * The end date of the price interval. This is the date that the price will stop billing @@ -582,42 +855,61 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - fun endDate(dateTime: OffsetDateTime) = apply { - this.endDate = EndDate.ofDateTime(dateTime) - } + /** + * The end date of the price interval. This is the date that the price will stop billing + * on the subscription. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.endDate = EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun endDate(dateTime: OffsetDateTime) = endDate(EndDate.ofDateTime(dateTime)) + + fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + endDate(EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to add to the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: List? - ) = apply { - this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions?.toMutableList() - } + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: Optional> ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) + /** A list of fixed fee quantity transitions to initialize on the price interval. */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + /** A list of fixed fee quantity transitions to initialize on the price interval. */ fun addFixedFeeQuantityTransition( fixedFeeQuantityTransition: FixedFeeQuantityTransition ) = apply { fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: mutableListOf()).apply { - add(fixedFeeQuantityTransition) + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) } } @@ -625,7 +917,8 @@ constructor( * The maximum amount that will be billed for this price interval for a given billing * period. */ - fun maximumAmount(maximumAmount: Double?) = apply { this.maximumAmount = maximumAmount } + fun maximumAmount(maximumAmount: Double?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** * The maximum amount that will be billed for this price interval for a given billing @@ -641,11 +934,20 @@ constructor( fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null) as Double?) + /** + * The maximum amount that will be billed for this price interval for a given billing + * period. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + /** * The minimum amount that will be billed for this price interval for a given billing * period. */ - fun minimumAmount(minimumAmount: Double?) = apply { this.minimumAmount = minimumAmount } + fun minimumAmount(minimumAmount: Double?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) /** * The minimum amount that will be billed for this price interval for a given billing @@ -661,170 +963,159 @@ constructor( fun minimumAmount(minimumAmount: Optional) = minimumAmount(minimumAmount.orElse(null) as Double?) + /** + * The minimum amount that will be billed for this price interval for a given billing + * period. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = apply { this.price = price } + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** The definition of a new price to create and add to the subscription. */ fun price(price: Optional) = price(price.orElse(null)) - fun price(newFloatingUnitPrice: Price.NewFloatingUnitPrice) = apply { - this.price = Price.ofNewFloatingUnitPrice(newFloatingUnitPrice) - } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } - fun price(newFloatingPackagePrice: Price.NewFloatingPackagePrice) = apply { - this.price = Price.ofNewFloatingPackagePrice(newFloatingPackagePrice) - } + fun price(newFloatingUnitPrice: Price.NewFloatingUnitPrice) = + price(Price.ofNewFloatingUnitPrice(newFloatingUnitPrice)) - fun price(newFloatingMatrixPrice: Price.NewFloatingMatrixPrice) = apply { - this.price = Price.ofNewFloatingMatrixPrice(newFloatingMatrixPrice) - } + fun price(newFloatingPackagePrice: Price.NewFloatingPackagePrice) = + price(Price.ofNewFloatingPackagePrice(newFloatingPackagePrice)) + + fun price(newFloatingMatrixPrice: Price.NewFloatingMatrixPrice) = + price(Price.ofNewFloatingMatrixPrice(newFloatingMatrixPrice)) fun price( newFloatingMatrixWithAllocationPrice: Price.NewFloatingMatrixWithAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingMatrixWithAllocationPrice( newFloatingMatrixWithAllocationPrice ) - } + ) - fun price(newFloatingTieredPrice: Price.NewFloatingTieredPrice) = apply { - this.price = Price.ofNewFloatingTieredPrice(newFloatingTieredPrice) - } + fun price(newFloatingTieredPrice: Price.NewFloatingTieredPrice) = + price(Price.ofNewFloatingTieredPrice(newFloatingTieredPrice)) - fun price(newFloatingTieredBpsPrice: Price.NewFloatingTieredBpsPrice) = apply { - this.price = Price.ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice) - } + fun price(newFloatingTieredBpsPrice: Price.NewFloatingTieredBpsPrice) = + price(Price.ofNewFloatingTieredBpsPrice(newFloatingTieredBpsPrice)) - fun price(newFloatingBpsPrice: Price.NewFloatingBpsPrice) = apply { - this.price = Price.ofNewFloatingBpsPrice(newFloatingBpsPrice) - } + fun price(newFloatingBpsPrice: Price.NewFloatingBpsPrice) = + price(Price.ofNewFloatingBpsPrice(newFloatingBpsPrice)) - fun price(newFloatingBulkBpsPrice: Price.NewFloatingBulkBpsPrice) = apply { - this.price = Price.ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice) - } + fun price(newFloatingBulkBpsPrice: Price.NewFloatingBulkBpsPrice) = + price(Price.ofNewFloatingBulkBpsPrice(newFloatingBulkBpsPrice)) - fun price(newFloatingBulkPrice: Price.NewFloatingBulkPrice) = apply { - this.price = Price.ofNewFloatingBulkPrice(newFloatingBulkPrice) - } + fun price(newFloatingBulkPrice: Price.NewFloatingBulkPrice) = + price(Price.ofNewFloatingBulkPrice(newFloatingBulkPrice)) fun price( newFloatingThresholdTotalAmountPrice: Price.NewFloatingThresholdTotalAmountPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingThresholdTotalAmountPrice( newFloatingThresholdTotalAmountPrice ) - } + ) - fun price(newFloatingTieredPackagePrice: Price.NewFloatingTieredPackagePrice) = apply { - this.price = Price.ofNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice) - } + fun price(newFloatingTieredPackagePrice: Price.NewFloatingTieredPackagePrice) = + price(Price.ofNewFloatingTieredPackagePrice(newFloatingTieredPackagePrice)) - fun price(newFloatingGroupedTieredPrice: Price.NewFloatingGroupedTieredPrice) = apply { - this.price = Price.ofNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice) - } + fun price(newFloatingGroupedTieredPrice: Price.NewFloatingGroupedTieredPrice) = + price(Price.ofNewFloatingGroupedTieredPrice(newFloatingGroupedTieredPrice)) fun price(newFloatingTieredWithMinimumPrice: Price.NewFloatingTieredWithMinimumPrice) = - apply { - this.price = - Price.ofNewFloatingTieredWithMinimumPrice(newFloatingTieredWithMinimumPrice) - } + price(Price.ofNewFloatingTieredWithMinimumPrice(newFloatingTieredWithMinimumPrice)) fun price( newFloatingPackageWithAllocationPrice: Price.NewFloatingPackageWithAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingPackageWithAllocationPrice( newFloatingPackageWithAllocationPrice ) - } + ) fun price( newFloatingTieredPackageWithMinimumPrice: Price.NewFloatingTieredPackageWithMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingTieredPackageWithMinimumPrice( newFloatingTieredPackageWithMinimumPrice ) - } + ) fun price(newFloatingUnitWithPercentPrice: Price.NewFloatingUnitWithPercentPrice) = - apply { - this.price = - Price.ofNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice) - } + price(Price.ofNewFloatingUnitWithPercentPrice(newFloatingUnitWithPercentPrice)) fun price( newFloatingTieredWithProrationPrice: Price.NewFloatingTieredWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingTieredWithProrationPrice(newFloatingTieredWithProrationPrice) - } + ) fun price(newFloatingUnitWithProrationPrice: Price.NewFloatingUnitWithProrationPrice) = - apply { - this.price = - Price.ofNewFloatingUnitWithProrationPrice(newFloatingUnitWithProrationPrice) - } + price(Price.ofNewFloatingUnitWithProrationPrice(newFloatingUnitWithProrationPrice)) fun price(newFloatingGroupedAllocationPrice: Price.NewFloatingGroupedAllocationPrice) = - apply { - this.price = - Price.ofNewFloatingGroupedAllocationPrice(newFloatingGroupedAllocationPrice) - } + price(Price.ofNewFloatingGroupedAllocationPrice(newFloatingGroupedAllocationPrice)) fun price( newFloatingGroupedWithProratedMinimumPrice: Price.NewFloatingGroupedWithProratedMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingGroupedWithProratedMinimumPrice( newFloatingGroupedWithProratedMinimumPrice ) - } + ) fun price( newFloatingGroupedWithMeteredMinimumPrice: Price.NewFloatingGroupedWithMeteredMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingGroupedWithMeteredMinimumPrice( newFloatingGroupedWithMeteredMinimumPrice ) - } + ) fun price( newFloatingMatrixWithDisplayNamePrice: Price.NewFloatingMatrixWithDisplayNamePrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingMatrixWithDisplayNamePrice( newFloatingMatrixWithDisplayNamePrice ) - } + ) fun price(newFloatingBulkWithProrationPrice: Price.NewFloatingBulkWithProrationPrice) = - apply { - this.price = - Price.ofNewFloatingBulkWithProrationPrice(newFloatingBulkWithProrationPrice) - } + price(Price.ofNewFloatingBulkWithProrationPrice(newFloatingBulkWithProrationPrice)) fun price( newFloatingGroupedTieredPackagePrice: Price.NewFloatingGroupedTieredPackagePrice - ) = apply { - this.price = + ) = + price( Price.ofNewFloatingGroupedTieredPackagePrice( newFloatingGroupedTieredPackagePrice ) - } + ) /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to add to the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to add to the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -848,10 +1139,10 @@ constructor( Add( checkNotNull(startDate) { "`startDate` is required but was not set" }, allocationPrice, - discounts?.toImmutable(), + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, endDate, externalPriceId, - fixedFeeQuantityTransitions?.toImmutable(), + (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, maximumAmount, minimumAmount, price, @@ -873,6 +1164,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -898,6 +1191,15 @@ constructor( } } + fun validate(): StartDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown StartDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -978,37 +1280,77 @@ constructor( class AllocationPrice @JsonCreator private constructor( - @JsonProperty("amount") private val amount: String, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("expires_at_end_of_cadence") private val expiresAtEndOfCadence: Boolean, + @JsonProperty("amount") + @ExcludeMissing + private val amount: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("expires_at_end_of_cadence") + @ExcludeMissing + private val expiresAtEndOfCadence: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** An amount of the currency to allocate to the customer at the specified cadence. */ - @JsonProperty("amount") fun amount(): String = amount + fun amount(): String = amount.getRequired("amount") + + /** The cadence at which to allocate the amount to the customer. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** + * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this + * price. + */ + fun currency(): String = currency.getRequired("currency") + + /** + * Whether the allocated amount should expire at the end of the cadence or roll over to + * the next period. + */ + fun expiresAtEndOfCadence(): Boolean = + expiresAtEndOfCadence.getRequired("expires_at_end_of_cadence") + + /** An amount of the currency to allocate to the customer at the specified cadence. */ + @JsonProperty("amount") @ExcludeMissing fun _amount(): JsonField = amount /** The cadence at which to allocate the amount to the customer. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") @ExcludeMissing fun _cadence(): JsonField = cadence /** * An ISO 4217 currency string or a custom pricing unit identifier in which to bill this * price. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") @ExcludeMissing fun _currency(): JsonField = currency /** * Whether the allocated amount should expire at the end of the cadence or roll over to * the next period. */ @JsonProperty("expires_at_end_of_cadence") - fun expiresAtEndOfCadence(): Boolean = expiresAtEndOfCadence + @ExcludeMissing + fun _expiresAtEndOfCadence(): JsonField = expiresAtEndOfCadence @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AllocationPrice = apply { + if (!validated) { + amount() + cadence() + currency() + expiresAtEndOfCadence() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1018,10 +1360,10 @@ constructor( class Builder { - private var amount: String? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var expiresAtEndOfCadence: Boolean? = null + private var amount: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var expiresAtEndOfCadence: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1036,22 +1378,43 @@ constructor( /** * An amount of the currency to allocate to the customer at the specified cadence. */ - fun amount(amount: String) = apply { this.amount = amount } + fun amount(amount: String) = amount(JsonField.of(amount)) + + /** + * An amount of the currency to allocate to the customer at the specified cadence. + */ + fun amount(amount: JsonField) = apply { this.amount = amount } + + /** The cadence at which to allocate the amount to the customer. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence at which to allocate the amount to the customer. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** * An ISO 4217 currency string or a custom pricing unit identifier in which to bill * this price. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** + * An ISO 4217 currency string or a custom pricing unit identifier in which to bill + * this price. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** + * Whether the allocated amount should expire at the end of the cadence or roll over + * to the next period. + */ + fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = + expiresAtEndOfCadence(JsonField.of(expiresAtEndOfCadence)) /** * Whether the allocated amount should expire at the end of the cadence or roll over * to the next period. */ - fun expiresAtEndOfCadence(expiresAtEndOfCadence: Boolean) = apply { + fun expiresAtEndOfCadence(expiresAtEndOfCadence: JsonField) = apply { this.expiresAtEndOfCadence = expiresAtEndOfCadence } @@ -1198,6 +1561,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun amountDiscountCreationParams(): Optional = Optional.ofNullable(amountDiscountCreationParams) @@ -1239,6 +1604,22 @@ constructor( } } + fun validate(): Discount = apply { + if (!validated) { + if ( + amountDiscountCreationParams == null && + percentageDiscountCreationParams == null && + usageDiscountCreationParams == null + ) { + throw OrbInvalidDataException("Unknown Discount: $_json") + } + amountDiscountCreationParams?.validate() + percentageDiscountCreationParams?.validate() + usageDiscountCreationParams?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1307,13 +1688,20 @@ constructor( when (discountType) { "amount" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Discount(amountDiscountCreationParams = it, _json = json) } } "percentage" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } ?.let { return Discount( percentageDiscountCreationParams = it, @@ -1322,7 +1710,9 @@ constructor( } } "usage" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Discount(usageDiscountCreationParams = it, _json = json) } @@ -1357,21 +1747,44 @@ constructor( class AmountDiscountCreationParams @JsonCreator private constructor( - @JsonProperty("amount_discount") private val amountDiscount: Double, - @JsonProperty("discount_type") private val discountType: DiscountType, + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") fun amountDiscount(): Double = amountDiscount + fun amountDiscount(): Double = amountDiscount.getRequired("amount_discount") + + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AmountDiscountCreationParams = apply { + if (!validated) { + amountDiscount() + discountType() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1381,8 +1794,8 @@ constructor( class Builder { - private var amountDiscount: Double? = null - private var discountType: DiscountType? = null + private var amountDiscount: JsonField? = null + private var discountType: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1395,11 +1808,18 @@ constructor( } /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: Double) = apply { + fun amountDiscount(amountDiscount: Double) = + amountDiscount(JsonField.of(amountDiscount)) + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } @@ -1511,25 +1931,51 @@ constructor( class PercentageDiscountCreationParams @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** * Only available if discount_type is `percentage`. This is a number between 0 * and 1. */ @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PercentageDiscountCreationParams = apply { + if (!validated) { + discountType() + percentageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1539,8 +1985,8 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var percentageDiscount: Double? = null + private var discountType: JsonField? = null + private var percentageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1553,7 +1999,10 @@ constructor( percentageDiscountCreationParams.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } @@ -1561,7 +2010,14 @@ constructor( * Only available if discount_type is `percentage`. This is a number between 0 * and 1. */ - fun percentageDiscount(percentageDiscount: Double) = apply { + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) + + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { this.percentageDiscount = percentageDiscount } @@ -1673,24 +2129,50 @@ constructor( class UsageDiscountCreationParams @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("usage_discount") private val usageDiscount: Double, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for. + */ + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** * Only available if discount_type is `usage`. Number of usage units that this * discount is for. */ - @JsonProperty("usage_discount") fun usageDiscount(): Double = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UsageDiscountCreationParams = apply { + if (!validated) { + discountType() + usageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1700,8 +2182,8 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var usageDiscount: Double? = null + private var discountType: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1713,7 +2195,10 @@ constructor( usageDiscountCreationParams.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } @@ -1721,7 +2206,14 @@ constructor( * Only available if discount_type is `usage`. Number of usage units that this * discount is for. */ - fun usageDiscount(usageDiscount: Double) = apply { + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) + + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for. + */ + fun usageDiscount(usageDiscount: JsonField) = apply { this.usageDiscount = usageDiscount } @@ -1843,6 +2335,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -1868,6 +2362,15 @@ constructor( } } + fun validate(): EndDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown EndDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1947,22 +2450,44 @@ constructor( class FixedFeeQuantityTransition @JsonCreator private constructor( - @JsonProperty("effective_date") private val effectiveDate: OffsetDateTime, - @JsonProperty("quantity") private val quantity: Long, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The date that the fixed fee quantity transition should take effect. */ - @JsonProperty("effective_date") fun effectiveDate(): OffsetDateTime = effectiveDate + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(): Long = quantity.getRequired("quantity") + + /** The date that the fixed fee quantity transition should take effect. */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** The quantity of the fixed fee quantity transition. */ - @JsonProperty("quantity") fun quantity(): Long = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + effectiveDate() + quantity() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1972,8 +2497,8 @@ constructor( class Builder { - private var effectiveDate: OffsetDateTime? = null - private var quantity: Long? = null + private var effectiveDate: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1985,12 +2510,19 @@ constructor( } /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(effectiveDate: OffsetDateTime) = apply { + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + /** The date that the fixed fee quantity transition should take effect. */ + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } /** The quantity of the fixed fee quantity transition. */ - fun quantity(quantity: Long) = apply { this.quantity = quantity } + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2095,6 +2627,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newFloatingUnitPrice(): Optional = Optional.ofNullable(newFloatingUnitPrice) @@ -2415,6 +2949,64 @@ constructor( } } + fun validate(): Price = apply { + if (!validated) { + if ( + newFloatingUnitPrice == null && + newFloatingPackagePrice == null && + newFloatingMatrixPrice == null && + newFloatingMatrixWithAllocationPrice == null && + newFloatingTieredPrice == null && + newFloatingTieredBpsPrice == null && + newFloatingBpsPrice == null && + newFloatingBulkBpsPrice == null && + newFloatingBulkPrice == null && + newFloatingThresholdTotalAmountPrice == null && + newFloatingTieredPackagePrice == null && + newFloatingGroupedTieredPrice == null && + newFloatingTieredWithMinimumPrice == null && + newFloatingPackageWithAllocationPrice == null && + newFloatingTieredPackageWithMinimumPrice == null && + newFloatingUnitWithPercentPrice == null && + newFloatingTieredWithProrationPrice == null && + newFloatingUnitWithProrationPrice == null && + newFloatingGroupedAllocationPrice == null && + newFloatingGroupedWithProratedMinimumPrice == null && + newFloatingGroupedWithMeteredMinimumPrice == null && + newFloatingMatrixWithDisplayNamePrice == null && + newFloatingBulkWithProrationPrice == null && + newFloatingGroupedTieredPackagePrice == null + ) { + throw OrbInvalidDataException("Unknown Price: $_json") + } + newFloatingUnitPrice?.validate() + newFloatingPackagePrice?.validate() + newFloatingMatrixPrice?.validate() + newFloatingMatrixWithAllocationPrice?.validate() + newFloatingTieredPrice?.validate() + newFloatingTieredBpsPrice?.validate() + newFloatingBpsPrice?.validate() + newFloatingBulkBpsPrice?.validate() + newFloatingBulkPrice?.validate() + newFloatingThresholdTotalAmountPrice?.validate() + newFloatingTieredPackagePrice?.validate() + newFloatingGroupedTieredPrice?.validate() + newFloatingTieredWithMinimumPrice?.validate() + newFloatingPackageWithAllocationPrice?.validate() + newFloatingTieredPackageWithMinimumPrice?.validate() + newFloatingUnitWithPercentPrice?.validate() + newFloatingTieredWithProrationPrice?.validate() + newFloatingUnitWithProrationPrice?.validate() + newFloatingGroupedAllocationPrice?.validate() + newFloatingGroupedWithProratedMinimumPrice?.validate() + newFloatingGroupedWithMeteredMinimumPrice?.validate() + newFloatingMatrixWithDisplayNamePrice?.validate() + newFloatingBulkWithProrationPrice?.validate() + newFloatingGroupedTieredPackagePrice?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -2731,25 +3323,36 @@ constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingUnitPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingUnitPrice = it, _json = json) + } } "package" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingPackagePrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingPackagePrice = it, _json = json) + } } "matrix" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingMatrixPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingMatrixPrice = it, _json = json) + } } "matrix_with_allocation" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingMatrixWithAllocationPrice = it, @@ -2758,35 +3361,52 @@ constructor( } } "tiered" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingTieredPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingTieredPrice = it, _json = json) + } } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingTieredBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingTieredBpsPrice = it, _json = json) + } } "bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingBpsPrice = it, _json = json) + } } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingBulkBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingBulkBpsPrice = it, _json = json) + } } "bulk" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newFloatingBulkPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newFloatingBulkPrice = it, _json = json) + } } "threshold_total_amount" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingThresholdTotalAmountPrice = it, @@ -2795,13 +3415,17 @@ constructor( } } "tiered_package" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newFloatingTieredPackagePrice = it, _json = json) } } "grouped_tiered" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newFloatingGroupedTieredPrice = it, _json = json) } @@ -2810,7 +3434,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingTieredWithMinimumPrice = it, @@ -2822,7 +3448,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingPackageWithAllocationPrice = it, @@ -2834,7 +3462,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingTieredPackageWithMinimumPrice = it, @@ -2843,7 +3473,12 @@ constructor( } } "unit_with_percent" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize( + node, + jacksonTypeRef() + ) { + it.validate() + } ?.let { return Price(newFloatingUnitWithPercentPrice = it, _json = json) } @@ -2852,7 +3487,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingTieredWithProrationPrice = it, @@ -2864,7 +3501,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingUnitWithProrationPrice = it, @@ -2876,7 +3515,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingGroupedAllocationPrice = it, @@ -2888,7 +3529,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingGroupedWithProratedMinimumPrice = it, @@ -2900,7 +3543,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingGroupedWithMeteredMinimumPrice = it, @@ -2912,7 +3557,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingMatrixWithDisplayNamePrice = it, @@ -2924,7 +3571,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingBulkWithProrationPrice = it, @@ -2936,7 +3585,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newFloatingGroupedTieredPackagePrice = it, @@ -3012,95 +3663,216 @@ constructor( } } - @NoAutoDetect - class NewFloatingUnitPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @NoAutoDetect + class NewFloatingUnitPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -3108,12 +3880,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingUnitPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3123,21 +3919,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3163,28 +3962,47 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -3193,13 +4011,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -3216,13 +4041,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -3232,12 +4065,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -3252,22 +4092,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -3284,22 +4134,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -3309,12 +4174,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -3323,6 +4196,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3504,18 +4384,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3525,7 +4421,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -3536,7 +4432,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -3595,22 +4496,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3620,8 +4545,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -3635,10 +4560,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -3759,22 +4691,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3784,8 +4740,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -3800,10 +4756,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -3933,6 +4896,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4014,91 +4985,212 @@ constructor( class NewFloatingPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -4106,12 +5198,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingPackagePrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4121,21 +5237,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4162,20 +5281,39 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } @@ -4183,9 +5321,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -4194,13 +5331,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -4217,13 +5361,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -4233,12 +5385,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -4253,22 +5412,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -4285,22 +5454,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -4310,12 +5494,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -4324,6 +5516,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4507,25 +5706,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") /** * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4535,8 +5761,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4548,7 +5774,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -4556,7 +5786,13 @@ constructor( * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { this.packageSize = packageSize } @@ -4620,22 +5856,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4645,8 +5905,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4660,10 +5920,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -4784,22 +6051,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4809,8 +6100,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4825,10 +6116,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -4958,6 +6256,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5039,91 +6345,212 @@ constructor( class NewFloatingMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -5131,12 +6558,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5146,21 +6597,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5186,30 +6640,48 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -5218,13 +6690,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -5237,9 +6716,17 @@ constructor( * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun billedInAdvance(billedInAdvance: Optional) = - billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun billedInAdvance(billedInAdvance: Optional) = + billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } /** * For custom cadence: specifies the duration of the billing period in days or @@ -5247,7 +6734,7 @@ constructor( */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -5257,12 +6744,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -5277,22 +6771,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -5309,22 +6813,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -5334,12 +6853,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -5348,6 +6875,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5479,31 +7013,66 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ @JsonProperty("matrix_values") - fun matrixValues(): List = matrixValues + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5513,17 +7082,17 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -5531,29 +7100,61 @@ constructor( * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { matrixValues = - (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -5586,11 +7187,11 @@ constructor( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -5600,28 +7201,55 @@ constructor( @JsonCreator private constructor( @JsonProperty("dimension_values") - private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5631,14 +7259,15 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() @@ -5649,8 +7278,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -5660,13 +7297,23 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { - add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -5697,7 +7344,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -5801,22 +7448,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5826,8 +7497,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -5841,10 +7512,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5965,22 +7643,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5990,8 +7692,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6006,10 +7708,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6139,6 +7848,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6220,94 +7937,215 @@ constructor( class NewFloatingMatrixWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), @JsonProperty("matrix_with_allocation_config") - private val matrixWithAllocationConfig: MatrixWithAllocationConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val matrixWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("matrix_with_allocation_config") fun matrixWithAllocationConfig(): MatrixWithAllocationConfig = + matrixWithAllocationConfig.getRequired("matrix_with_allocation_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("matrix_with_allocation_config") + @ExcludeMissing + fun _matrixWithAllocationConfig(): JsonField = matrixWithAllocationConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -6315,12 +8153,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixWithAllocationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + matrixWithAllocationConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6330,21 +8192,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var matrixWithAllocationConfig: MatrixWithAllocationConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithAllocationConfig: JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6374,30 +8240,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixWithAllocationConfig( + matrixWithAllocationConfig: MatrixWithAllocationConfig + ) = matrixWithAllocationConfig(JsonField.of(matrixWithAllocationConfig)) fun matrixWithAllocationConfig( - matrixWithAllocationConfig: MatrixWithAllocationConfig + matrixWithAllocationConfig: JsonField ) = apply { this.matrixWithAllocationConfig = matrixWithAllocationConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -6406,13 +8291,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -6429,13 +8321,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -6445,12 +8345,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -6465,22 +8372,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -6497,22 +8414,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -6522,12 +8454,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -6536,6 +8476,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6667,35 +8614,78 @@ constructor( class MatrixWithAllocationConfig @JsonCreator private constructor( - @JsonProperty("allocation") private val allocation: Double, - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("allocation") + @ExcludeMissing + private val allocation: JsonField = JsonMissing.of(), + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Allocation to be used to calculate the price */ - @JsonProperty("allocation") fun allocation(): Double = allocation + fun allocation(): Double = allocation.getRequired("allocation") + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + + /** Allocation to be used to calculate the price */ + @JsonProperty("allocation") + @ExcludeMissing + fun _allocation(): JsonField = allocation /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ @JsonProperty("matrix_values") - fun matrixValues(): List = matrixValues + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixWithAllocationConfig = apply { + if (!validated) { + allocation() + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6705,10 +8695,10 @@ constructor( class Builder { - private var allocation: Double? = null - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var allocation: JsonField? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6717,43 +8707,83 @@ constructor( apply { allocation = matrixWithAllocationConfig.allocation defaultUnitAmount = matrixWithAllocationConfig.defaultUnitAmount - dimensions = matrixWithAllocationConfig.dimensions.toMutableList() + dimensions = + matrixWithAllocationConfig.dimensions.map { it.toMutableList() } matrixValues = - matrixWithAllocationConfig.matrixValues.toMutableList() + matrixWithAllocationConfig.matrixValues.map { + it.toMutableList() + } additionalProperties = matrixWithAllocationConfig.additionalProperties.toMutableMap() } /** Allocation to be used to calculate the price */ - fun allocation(allocation: Double) = apply { this.allocation = allocation } + fun allocation(allocation: Double) = allocation(JsonField.of(allocation)) + + /** Allocation to be used to calculate the price */ + fun allocation(allocation: JsonField) = apply { + this.allocation = allocation + } /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { matrixValues = - (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -6789,11 +8819,11 @@ constructor( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -6803,28 +8833,55 @@ constructor( @JsonCreator private constructor( @JsonProperty("dimension_values") - private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6834,14 +8891,15 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() @@ -6852,8 +8910,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -6863,13 +8929,23 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { - add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -6900,7 +8976,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -7004,22 +9080,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7029,8 +9129,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -7044,10 +9144,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7168,22 +9275,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7193,8 +9324,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -7209,10 +9340,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7342,6 +9480,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7423,91 +9569,212 @@ constructor( class NewFloatingTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -7515,12 +9782,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7530,21 +9821,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7570,20 +9864,39 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } @@ -7591,9 +9904,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -7602,13 +9914,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -7625,13 +9944,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -7641,12 +9968,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -7661,22 +9995,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -7693,22 +10037,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -7718,12 +10077,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -7732,6 +10099,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -7915,18 +10289,34 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7936,26 +10326,42 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** * Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for rating based on total usage quantities into the specified tier + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -7983,7 +10389,7 @@ constructor( fun build(): TieredConfig = TieredConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -7992,30 +10398,64 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") + + /** Amount per unit */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Exclusive tier ending value. If null, this is treated as the last tier + */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** * Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8025,9 +10465,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8040,10 +10480,19 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -8051,7 +10500,8 @@ constructor( * Exclusive tier ending value. If null, this is treated as the last * tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = + lastUnit(JsonField.ofNullable(lastUnit)) /** * Exclusive tier ending value. If null, this is treated as the last @@ -8069,6 +10519,14 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** + * Exclusive tier ending value. If null, this is treated as the last + * tier + */ + fun lastUnit(lastUnit: JsonField) = apply { + this.lastUnit = lastUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8148,22 +10606,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8173,8 +10655,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -8188,10 +10670,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8312,22 +10801,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8337,8 +10850,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -8353,10 +10866,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8486,6 +11006,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8567,92 +11095,213 @@ constructor( class NewFloatingTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_bps_config") - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -8660,12 +11309,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredBpsPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8675,21 +11348,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -8717,20 +11393,39 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } @@ -8738,9 +11433,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -8749,13 +11443,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -8772,13 +11473,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -8788,12 +11497,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -8808,22 +11524,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -8840,22 +11566,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -8865,12 +11606,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -8879,6 +11628,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9062,7 +11818,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -9071,12 +11829,29 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9086,13 +11861,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -9101,14 +11876,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -9136,7 +11928,7 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -9145,33 +11937,71 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Inclusive tier starting value */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9181,10 +12011,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9198,31 +12028,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9301,22 +12146,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9326,8 +12195,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -9341,10 +12210,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9465,22 +12341,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9490,8 +12390,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -9506,10 +12406,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9639,6 +12546,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9703,108 +12618,229 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingTieredBpsPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredBpsConfig == other.tieredBpsConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingBpsPrice + @JsonCreator + private constructor( + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredBpsConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingTieredBpsPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredBpsConfig=$tieredBpsConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingBpsPrice - @JsonCreator - private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -9812,12 +12848,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9827,21 +12887,24 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9866,29 +12929,48 @@ constructor( newFloatingBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -9897,13 +12979,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -9920,13 +13009,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -9936,12 +13033,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -9956,22 +13060,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -9988,22 +13102,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -10013,12 +13142,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -10027,6 +13164,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10074,23 +13218,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10100,8 +13266,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10113,17 +13279,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10314,22 +13487,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10339,8 +13536,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -10354,10 +13551,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10478,22 +13682,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10503,8 +13731,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -10519,10 +13747,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10652,6 +13887,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10733,91 +13976,212 @@ constructor( class NewFloatingBulkBpsPrice @JsonCreator private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -10825,12 +14189,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10840,21 +14228,24 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10880,31 +14271,49 @@ constructor( newFloatingBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -10913,13 +14322,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -10936,13 +14352,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -10952,12 +14376,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -10972,22 +14403,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -11004,22 +14445,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -11029,12 +14485,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -11043,6 +14507,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -11092,7 +14563,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -11101,12 +14574,29 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single + * tier based on total volume + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11116,13 +14606,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -11130,14 +14620,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a + * single tier based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -11165,7 +14672,7 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -11174,29 +14681,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11206,9 +14743,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11221,26 +14758,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11450,22 +14998,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11475,8 +15047,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -11490,10 +15062,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11614,22 +15193,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11639,8 +15242,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -11655,10 +15258,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11788,6 +15398,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11869,91 +15487,212 @@ constructor( class NewFloatingBulkPrice @JsonCreator private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -11961,12 +15700,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11976,21 +15739,24 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12015,29 +15781,48 @@ constructor( newFloatingBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -12046,13 +15831,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -12069,13 +15861,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -12085,12 +15885,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -12105,22 +15912,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -12137,22 +15954,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -12162,12 +15994,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -12176,6 +16016,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -12223,18 +16070,34 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12244,22 +16107,36 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -12287,7 +16164,7 @@ constructor( fun build(): BulkConfig = BulkConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -12296,24 +16173,48 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12323,8 +16224,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12336,14 +16237,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits - } + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = @@ -12356,6 +16260,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -12566,22 +16475,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12591,8 +16524,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -12606,10 +16539,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12730,22 +16670,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12755,8 +16719,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -12771,10 +16735,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12904,6 +16875,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12968,61 +16947,174 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingBulkPrice && bulkConfig == other.bulkConfig && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingThresholdTotalAmountPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(bulkConfig, cadence, currency, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingBulkPrice{bulkConfig=$bulkConfig, cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingThresholdTotalAmountPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("threshold_total_amount_config") - fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = thresholdTotalAmountConfig /** @@ -13030,49 +17122,57 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -13080,12 +17180,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13095,21 +17219,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13139,30 +17267,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig( thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -13171,13 +17318,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -13194,13 +17348,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -13210,12 +17372,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -13230,22 +17399,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -13262,22 +17441,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -13287,12 +17481,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -13301,6 +17503,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -13492,6 +17701,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13563,22 +17780,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13588,8 +17829,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -13603,10 +17844,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13727,22 +17975,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13752,8 +18024,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -13768,10 +18040,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13901,6 +18180,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13960,115 +18247,235 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingThresholdTotalAmountPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredPackagePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_config") + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - return /* spotless:off */ other is NewFloatingThresholdTotalAmountPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && thresholdTotalAmountConfig == other.thresholdTotalAmountConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, thresholdTotalAmountConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingThresholdTotalAmountPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, thresholdTotalAmountConfig=$thresholdTotalAmountConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingTieredPackagePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_package_config") - private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -14076,12 +18483,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPackagePrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14091,21 +18522,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14134,30 +18568,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -14166,13 +18619,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -14189,13 +18649,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -14205,12 +18673,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -14225,22 +18700,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -14257,22 +18742,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -14282,12 +18782,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -14296,6 +18804,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -14487,6 +19002,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14557,22 +19080,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14582,8 +19129,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14597,10 +19144,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14721,22 +19275,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14746,8 +19324,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14762,10 +19340,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14895,6 +19480,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14959,110 +19552,230 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingTieredPackagePrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageConfig == other.tieredPackageConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedTieredPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_tiered_config") + @ExcludeMissing + private val groupedTieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedTieredConfig(): GroupedTieredConfig = + groupedTieredConfig.getRequired("grouped_tiered_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingTieredPackagePrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageConfig=$tieredPackageConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingGroupedTieredPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("grouped_tiered_config") - private val groupedTieredConfig: GroupedTieredConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonProperty("grouped_tiered_config") - fun groupedTieredConfig(): GroupedTieredConfig = groupedTieredConfig + @ExcludeMissing + fun _groupedTieredConfig(): JsonField = groupedTieredConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -15070,12 +19783,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedTieredPrice = apply { + if (!validated) { + cadence() + currency() + groupedTieredConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15085,21 +19822,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedTieredConfig: GroupedTieredConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedTieredConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15128,30 +19868,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) - fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = apply { - this.groupedTieredConfig = groupedTieredConfig - } + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + fun groupedTieredConfig(groupedTieredConfig: GroupedTieredConfig) = + groupedTieredConfig(JsonField.of(groupedTieredConfig)) + + fun groupedTieredConfig(groupedTieredConfig: JsonField) = + apply { + this.groupedTieredConfig = groupedTieredConfig + } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -15160,13 +19919,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -15183,13 +19949,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -15199,12 +19973,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -15219,22 +20000,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -15251,22 +20042,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -15276,12 +20082,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -15290,6 +20104,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15429,6 +20250,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedTieredConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15551,22 +20380,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15576,8 +20429,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -15591,10 +20444,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15715,22 +20575,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15740,8 +20624,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -15756,10 +20640,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15889,6 +20780,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15953,110 +20852,232 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedTieredPrice && cadence == other.cadence && currency == other.currency && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingGroupedTieredPrice && cadence == other.cadence && currency == other.currency && groupedTieredConfig == other.groupedTieredConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_minimum_config") + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedTieredConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingGroupedTieredPrice{cadence=$cadence, currency=$currency, groupedTieredConfig=$groupedTieredConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingTieredWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -16064,12 +21085,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16079,21 +21124,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16123,31 +21171,48 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -16156,13 +21221,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -16179,13 +21251,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -16195,12 +21275,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -16215,22 +21302,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -16247,22 +21344,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -16272,12 +21384,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -16286,6 +21406,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16477,6 +21604,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16548,22 +21683,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16573,8 +21732,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -16588,10 +21747,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16712,22 +21878,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16737,8 +21927,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -16753,10 +21943,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16886,6 +22083,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16945,66 +22150,179 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingTieredWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingPackageWithAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - return /* spotless:off */ other is NewFloatingTieredWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithMinimumConfig == other.tieredWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingTieredWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithMinimumConfig=$tieredWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingPackageWithAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("package_with_allocation_config") - fun packageWithAllocationConfig(): PackageWithAllocationConfig = + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = packageWithAllocationConfig /** @@ -17012,49 +22330,57 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -17062,12 +22388,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17077,21 +22427,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17124,30 +22479,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -17156,13 +22530,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -17179,13 +22560,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -17195,12 +22584,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -17215,22 +22611,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -17247,22 +22653,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -17272,12 +22693,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -17286,6 +22715,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -17477,6 +22913,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17549,22 +22993,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17574,8 +23042,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -17589,10 +23057,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17713,22 +23188,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17738,8 +23237,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -17754,10 +23253,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17887,6 +23393,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17951,61 +23465,175 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingPackageWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingPackageWithAllocationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && packageWithAllocationConfig == other.packageWithAllocationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredPackageWithMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_package_with_minimum_config") + @ExcludeMissing + private val tieredPackageWithMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + tieredPackageWithMinimumConfig.getRequired("tiered_package_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, packageWithAllocationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingPackageWithAllocationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, packageWithAllocationConfig=$packageWithAllocationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingTieredPackageWithMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_package_with_minimum_config") - private val tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_with_minimum_config") - fun tieredPackageWithMinimumConfig(): TieredPackageWithMinimumConfig = + @ExcludeMissing + fun _tieredPackageWithMinimumConfig(): JsonField = tieredPackageWithMinimumConfig /** @@ -18013,49 +23641,57 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -18063,12 +23699,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredPackageWithMinimumPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredPackageWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18078,22 +23738,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig? = + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageWithMinimumConfig: + JsonField? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18127,21 +23791,41 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredPackageWithMinimumConfig( tieredPackageWithMinimumConfig: TieredPackageWithMinimumConfig + ) = tieredPackageWithMinimumConfig(JsonField.of(tieredPackageWithMinimumConfig)) + + fun tieredPackageWithMinimumConfig( + tieredPackageWithMinimumConfig: JsonField ) = apply { this.tieredPackageWithMinimumConfig = tieredPackageWithMinimumConfig } @@ -18150,9 +23834,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -18161,13 +23844,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -18184,13 +23874,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -18200,12 +23898,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -18220,22 +23925,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -18252,22 +23967,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -18277,12 +24007,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -18291,6 +24029,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -18483,6 +24228,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18555,22 +24308,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18580,8 +24357,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -18595,10 +24372,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18719,22 +24503,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18744,8 +24552,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -18760,10 +24568,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18893,6 +24708,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18957,110 +24780,232 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingTieredPackageWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingTieredPackageWithMinimumPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredPackageWithMinimumConfig == other.tieredPackageWithMinimumConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingUnitWithPercentPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_percent_config") + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredPackageWithMinimumConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingTieredPackageWithMinimumPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredPackageWithMinimumConfig=$tieredPackageWithMinimumConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingUnitWithPercentPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -19068,12 +25013,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingUnitWithPercentPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19083,21 +25052,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19127,31 +25099,48 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -19160,13 +25149,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -19183,13 +25179,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -19199,12 +25203,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -19219,22 +25230,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -19251,22 +25272,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -19276,12 +25312,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -19290,6 +25334,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19481,6 +25532,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19551,22 +25610,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19576,8 +25659,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -19591,10 +25674,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19715,22 +25805,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19740,8 +25854,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -19756,10 +25870,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19889,6 +26010,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19948,66 +26077,179 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingUnitWithPercentPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingTieredWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - return /* spotless:off */ other is NewFloatingUnitWithPercentPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithPercentConfig == other.unitWithPercentConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithPercentConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingUnitWithPercentPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithPercentConfig=$unitWithPercentConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingTieredWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_proration_config") - fun tieredWithProrationConfig(): TieredWithProrationConfig = + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = tieredWithProrationConfig /** @@ -20015,49 +26257,57 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -20065,12 +26315,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingTieredWithProrationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20080,21 +26354,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20124,30 +26402,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig( tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -20156,13 +26453,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -20179,13 +26483,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -20195,12 +26507,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -20215,22 +26534,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -20247,22 +26576,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -20272,12 +26616,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -20286,6 +26638,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -20477,6 +26836,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20548,22 +26915,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20573,8 +26964,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -20588,10 +26979,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20712,22 +27110,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20737,8 +27159,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -20753,10 +27175,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20886,6 +27315,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20950,110 +27387,232 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingTieredWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingTieredWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && tieredWithProrationConfig == other.tieredWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingUnitWithProrationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_with_proration_config") + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, tieredWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingTieredWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, tieredWithProrationConfig=$tieredWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingUnitWithProrationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -21061,12 +27620,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingUnitWithProrationPrice = apply { + if (!validated) { + cadence() + currency() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21076,21 +27659,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21120,31 +27706,48 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -21153,13 +27756,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -21176,13 +27786,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -21192,12 +27810,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -21212,22 +27837,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -21244,22 +27879,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -21269,12 +27919,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -21283,6 +27941,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21474,6 +28139,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21545,22 +28218,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21570,8 +28267,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -21585,10 +28282,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21709,22 +28413,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21734,8 +28462,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -21750,10 +28478,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21883,6 +28618,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21942,115 +28685,237 @@ constructor( override fun toString() = "Metadata{additionalProperties=$additionalProperties}" } - override fun equals(other: Any?): Boolean { - if (this === other) { - return true - } + override fun equals(other: Any?): Boolean { + if (this === other) { + return true + } + + return /* spotless:off */ other is NewFloatingUnitWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedAllocationPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_allocation_config") + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - return /* spotless:off */ other is NewFloatingUnitWithProrationPrice && cadence == other.cadence && currency == other.currency && itemId == other.itemId && modelType == other.modelType && name == other.name && unitWithProrationConfig == other.unitWithProrationConfig && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, itemId, modelType, name, unitWithProrationConfig, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun hashCode(): Int = hashCode + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - override fun toString() = - "NewFloatingUnitWithProrationPrice{cadence=$cadence, currency=$currency, itemId=$itemId, modelType=$modelType, name=$name, unitWithProrationConfig=$unitWithProrationConfig, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) - @NoAutoDetect - class NewFloatingGroupedAllocationPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -22058,12 +28923,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedAllocationPrice = apply { + if (!validated) { + cadence() + currency() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22073,21 +28962,24 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22117,31 +29009,48 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -22150,13 +29059,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -22173,13 +29089,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -22189,12 +29113,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -22209,22 +29140,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -22241,22 +29182,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -22266,12 +29222,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -22280,6 +29244,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22419,6 +29390,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22542,22 +29521,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22567,8 +29570,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -22582,10 +29585,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22706,22 +29716,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22731,8 +29765,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -22747,10 +29781,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22880,6 +29921,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22944,111 +29993,235 @@ constructor( return true } - return /* spotless:off */ other is NewFloatingGroupedAllocationPrice && cadence == other.cadence && currency == other.currency && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ - } + return /* spotless:off */ other is NewFloatingGroupedAllocationPrice && cadence == other.cadence && currency == other.currency && groupedAllocationConfig == other.groupedAllocationConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ + } + + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedWithProratedMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedAllocationConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingGroupedAllocationPrice{cadence=$cadence, currency=$currency, groupedAllocationConfig=$groupedAllocationConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingGroupedWithProratedMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonProperty("grouped_with_prorated_minimum_config") - fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -23056,12 +30229,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + currency() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23071,23 +30268,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null private var groupedWithProratedMinimumConfig: - GroupedWithProratedMinimumConfig? = + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23123,32 +30323,55 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -23157,13 +30380,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -23180,13 +30410,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -23196,12 +30434,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -23216,22 +30461,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -23248,22 +30503,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -23273,12 +30543,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -23287,6 +30565,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23426,6 +30711,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23551,22 +30844,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23576,8 +30893,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -23591,10 +30908,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23715,22 +31039,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23740,8 +31088,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -23756,10 +31104,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23889,6 +31244,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23956,108 +31319,232 @@ constructor( return /* spotless:off */ other is NewFloatingGroupedWithProratedMinimumPrice && cadence == other.cadence && currency == other.currency && groupedWithProratedMinimumConfig == other.groupedWithProratedMinimumConfig && itemId == other.itemId && modelType == other.modelType && name == other.name && billableMetricId == other.billableMetricId && billedInAdvance == other.billedInAdvance && billingCycleConfiguration == other.billingCycleConfiguration && conversionRate == other.conversionRate && externalPriceId == other.externalPriceId && fixedPriceQuantity == other.fixedPriceQuantity && invoiceGroupingKey == other.invoiceGroupingKey && invoicingCycleConfiguration == other.invoicingCycleConfiguration && metadata == other.metadata && additionalProperties == other.additionalProperties /* spotless:on */ } - /* spotless:off */ - private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } - /* spotless:on */ + /* spotless:off */ + private val hashCode: Int by lazy { Objects.hash(cadence, currency, groupedWithProratedMinimumConfig, itemId, modelType, name, billableMetricId, billedInAdvance, billingCycleConfiguration, conversionRate, externalPriceId, fixedPriceQuantity, invoiceGroupingKey, invoicingCycleConfiguration, metadata, additionalProperties) } + /* spotless:on */ + + override fun hashCode(): Int = hashCode + + override fun toString() = + "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" + } + + @NoAutoDetect + class NewFloatingGroupedWithMeteredMinimumPrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("grouped_with_metered_minimum_config") + @ExcludeMissing + private val groupedWithMeteredMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + groupedWithMeteredMinimumConfig.getRequired( + "grouped_with_metered_minimum_config" + ) + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) - override fun hashCode(): Int = hashCode + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) - override fun toString() = - "NewFloatingGroupedWithProratedMinimumPrice{cadence=$cadence, currency=$currency, groupedWithProratedMinimumConfig=$groupedWithProratedMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" - } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) - @NoAutoDetect - class NewFloatingGroupedWithMeteredMinimumPrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("grouped_with_metered_minimum_config") - private val groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency @JsonProperty("grouped_with_metered_minimum_config") - fun groupedWithMeteredMinimumConfig(): GroupedWithMeteredMinimumConfig = + @ExcludeMissing + fun _groupedWithMeteredMinimumConfig(): JsonField = groupedWithMeteredMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -24065,12 +31552,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedWithMeteredMinimumPrice = apply { + if (!validated) { + cadence() + currency() + groupedWithMeteredMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24080,22 +31591,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig? = + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedWithMeteredMinimumConfig: + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24131,32 +31646,54 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: String) = currency(JsonField.of(currency)) + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedWithMeteredMinimumConfig( groupedWithMeteredMinimumConfig: GroupedWithMeteredMinimumConfig + ) = + groupedWithMeteredMinimumConfig( + JsonField.of(groupedWithMeteredMinimumConfig) + ) + + fun groupedWithMeteredMinimumConfig( + groupedWithMeteredMinimumConfig: JsonField ) = apply { this.groupedWithMeteredMinimumConfig = groupedWithMeteredMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -24165,13 +31702,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -24188,13 +31732,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -24204,12 +31756,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -24224,22 +31783,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -24256,22 +31825,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -24281,12 +31865,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -24295,6 +31887,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24434,6 +32033,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithMeteredMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24559,22 +32166,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24584,8 +32215,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -24599,10 +32230,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -24723,22 +32361,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24748,8 +32410,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -24764,10 +32426,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -24897,6 +32566,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24974,98 +32651,219 @@ constructor( "NewFloatingGroupedWithMeteredMinimumPrice{cadence=$cadence, currency=$currency, groupedWithMeteredMinimumConfig=$groupedWithMeteredMinimumConfig, itemId=$itemId, modelType=$modelType, name=$name, billableMetricId=$billableMetricId, billedInAdvance=$billedInAdvance, billingCycleConfiguration=$billingCycleConfiguration, conversionRate=$conversionRate, externalPriceId=$externalPriceId, fixedPriceQuantity=$fixedPriceQuantity, invoiceGroupingKey=$invoiceGroupingKey, invoicingCycleConfiguration=$invoicingCycleConfiguration, metadata=$metadata, additionalProperties=$additionalProperties}" } - @NoAutoDetect - class NewFloatingMatrixWithDisplayNamePrice - @JsonCreator - private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_with_display_name_config") - private val matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, - @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, - @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonAnySetter - private val additionalProperties: Map = immutableEmptyMap(), - ) { + @NoAutoDetect + class NewFloatingMatrixWithDisplayNamePrice + @JsonCreator + private constructor( + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_with_display_name_config") + @ExcludeMissing + private val matrixWithDisplayNameConfig: JsonField = + JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_configuration") + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_cycle_configuration") + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonAnySetter + private val additionalProperties: Map = immutableEmptyMap(), + ) { + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + matrixWithDisplayNameConfig.getRequired("matrix_with_display_name_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId @JsonProperty("matrix_with_display_name_config") - fun matrixWithDisplayNameConfig(): MatrixWithDisplayNameConfig = + @ExcludeMissing + fun _matrixWithDisplayNameConfig(): JsonField = matrixWithDisplayNameConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -25073,12 +32871,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingMatrixWithDisplayNamePrice = apply { + if (!validated) { + cadence() + currency() + itemId() + matrixWithDisplayNameConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25088,21 +32910,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var matrixWithDisplayNameConfig: + JsonField? = + null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -25135,30 +32962,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } fun matrixWithDisplayNameConfig( matrixWithDisplayNameConfig: MatrixWithDisplayNameConfig + ) = matrixWithDisplayNameConfig(JsonField.of(matrixWithDisplayNameConfig)) + + fun matrixWithDisplayNameConfig( + matrixWithDisplayNameConfig: JsonField ) = apply { this.matrixWithDisplayNameConfig = matrixWithDisplayNameConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -25167,13 +33013,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -25190,13 +33043,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -25206,12 +33067,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -25226,22 +33094,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -25258,22 +33136,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -25283,12 +33176,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -25297,6 +33198,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -25436,6 +33344,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixWithDisplayNameConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25560,22 +33476,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25585,8 +33525,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -25600,10 +33540,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -25724,22 +33671,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25749,8 +33720,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -25765,10 +33736,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -25898,6 +33876,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25980,92 +33966,214 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(): String = currency.getRequired("currency") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -26073,12 +34181,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + currency() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -26088,21 +34220,24 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var currency: String? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26132,31 +34267,48 @@ constructor( } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -26165,13 +34317,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -26188,13 +34347,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -26204,12 +34371,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -26224,22 +34398,32 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) - /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate } + /** An alias for the price. */ + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) + /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -26256,22 +34440,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -26281,12 +34480,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -26295,6 +34502,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -26352,6 +34566,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -26557,22 +34779,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -26582,8 +34828,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -26597,10 +34843,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -26721,22 +34974,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -26746,8 +35023,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -26762,10 +35039,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -26895,6 +35179,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -26976,94 +35268,215 @@ constructor( class NewFloatingGroupedTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("currency") private val currency: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), @JsonProperty("grouped_tiered_package_config") - private val groupedTieredPackageConfig: GroupedTieredPackageConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedTieredPackageConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** An ISO 4217 currency string for which this price is billed in. */ - @JsonProperty("currency") fun currency(): String = currency + fun currency(): String = currency.getRequired("currency") - @JsonProperty("grouped_tiered_package_config") fun groupedTieredPackageConfig(): GroupedTieredPackageConfig = + groupedTieredPackageConfig.getRequired("grouped_tiered_package_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** An ISO 4217 currency string for which this price is billed in. */ + @JsonProperty("currency") + @ExcludeMissing + fun _currency(): JsonField = currency + + @JsonProperty("grouped_tiered_package_config") + @ExcludeMissing + fun _groupedTieredPackageConfig(): JsonField = groupedTieredPackageConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -27071,12 +35484,36 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewFloatingGroupedTieredPackagePrice = apply { + if (!validated) { + cadence() + currency() + groupedTieredPackageConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27086,21 +35523,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var currency: String? = null - private var groupedTieredPackageConfig: GroupedTieredPackageConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null + private var cadence: JsonField? = null + private var currency: JsonField? = null + private var groupedTieredPackageConfig: JsonField? = + null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27130,30 +35571,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** An ISO 4217 currency string for which this price is billed in. */ + fun currency(currency: String) = currency(JsonField.of(currency)) /** An ISO 4217 currency string for which this price is billed in. */ - fun currency(currency: String) = apply { this.currency = currency } + fun currency(currency: JsonField) = apply { this.currency = currency } fun groupedTieredPackageConfig( groupedTieredPackageConfig: GroupedTieredPackageConfig + ) = groupedTieredPackageConfig(JsonField.of(groupedTieredPackageConfig)) + + fun groupedTieredPackageConfig( + groupedTieredPackageConfig: JsonField ) = apply { this.groupedTieredPackageConfig = groupedTieredPackageConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -27162,13 +35622,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -27185,13 +35652,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -27201,12 +35676,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -27217,26 +35699,36 @@ constructor( /** * The per unit conversion rate of the price currency to the invoicing currency. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun conversionRate(conversionRate: Optional) = - conversionRate(conversionRate.orElse(null) as Double?) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun conversionRate(conversionRate: Optional) = + conversionRate(conversionRate.orElse(null) as Double?) + + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -27253,22 +35745,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -27278,12 +35785,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -27292,6 +35807,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -27431,6 +35953,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedTieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27554,22 +36084,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27579,8 +36133,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27594,10 +36148,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -27718,22 +36279,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27743,8 +36328,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27759,10 +36344,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -27892,6 +36484,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27992,32 +36592,68 @@ constructor( class AddAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment") private val adjustment: Adjustment, - @JsonProperty("start_date") private val startDate: StartDate, - @JsonProperty("end_date") private val endDate: EndDate?, + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") fun adjustment(): Adjustment = adjustment + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(): StartDate = startDate.getRequired("start_date") + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** * The start date of the adjustment interval. This is the date that the adjustment will * start affecting prices on the subscription. */ - @JsonProperty("start_date") fun startDate(): StartDate = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * The end date of the adjustment interval. This is the date that the adjustment will stop * affecting prices on the subscription. */ - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddAdjustment = apply { + if (!validated) { + adjustment() + startDate() + endDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28027,9 +36663,9 @@ constructor( class Builder { - private var adjustment: Adjustment? = null - private var startDate: StartDate? = null - private var endDate: EndDate? = null + private var adjustment: JsonField? = null + private var startDate: JsonField? = null + private var endDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -28041,47 +36677,50 @@ constructor( } /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = apply { this.adjustment = adjustment } + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = apply { - this.adjustment = Adjustment.ofNewPercentageDiscount(newPercentageDiscount) + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment } - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = apply { - this.adjustment = Adjustment.ofNewUsageDiscount(newUsageDiscount) - } + fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = + adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = apply { - this.adjustment = Adjustment.ofNewAmountDiscount(newAmountDiscount) - } + fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = + adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - fun adjustment(newMinimum: Adjustment.NewMinimum) = apply { - this.adjustment = Adjustment.ofNewMinimum(newMinimum) - } + fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = + adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - fun adjustment(newMaximum: Adjustment.NewMaximum) = apply { - this.adjustment = Adjustment.ofNewMaximum(newMaximum) - } + fun adjustment(newMinimum: Adjustment.NewMinimum) = + adjustment(Adjustment.ofNewMinimum(newMinimum)) + + fun adjustment(newMaximum: Adjustment.NewMaximum) = + adjustment(Adjustment.ofNewMaximum(newMaximum)) /** * The start date of the adjustment interval. This is the date that the adjustment will * start affecting prices on the subscription. */ - fun startDate(startDate: StartDate) = apply { this.startDate = startDate } + fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) - fun startDate(dateTime: OffsetDateTime) = apply { - this.startDate = StartDate.ofDateTime(dateTime) - } + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. + */ + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.startDate = StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) + + fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + startDate(StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) /** * The end date of the adjustment interval. This is the date that the adjustment will * stop affecting prices on the subscription. */ - fun endDate(endDate: EndDate?) = apply { this.endDate = endDate } + fun endDate(endDate: EndDate?) = endDate(JsonField.ofNullable(endDate)) /** * The end date of the adjustment interval. This is the date that the adjustment will @@ -28089,13 +36728,16 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - fun endDate(dateTime: OffsetDateTime) = apply { - this.endDate = EndDate.ofDateTime(dateTime) - } + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.endDate = EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun endDate(dateTime: OffsetDateTime) = endDate(EndDate.ofDateTime(dateTime)) + + fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + endDate(EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28138,6 +36780,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newPercentageDiscount(): Optional = Optional.ofNullable(newPercentageDiscount) @@ -28188,6 +36832,26 @@ constructor( } } + fun validate(): Adjustment = apply { + if (!validated) { + if ( + newPercentageDiscount == null && + newUsageDiscount == null && + newAmountDiscount == null && + newMinimum == null && + newMaximum == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + newPercentageDiscount?.validate() + newUsageDiscount?.validate() + newAmountDiscount?.validate() + newMinimum?.validate() + newMaximum?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -28257,29 +36921,40 @@ constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newPercentageDiscount = it, _json = json) + } } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newUsageDiscount = it, _json = json) + } } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newAmountDiscount = it, _json = json) + } } "minimum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMinimum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMinimum = it, _json = json) + } } "maximum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMaximum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMaximum = it, _json = json) + } } } @@ -28313,35 +36988,75 @@ constructor( class NewPercentageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPercentageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + percentageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28351,47 +37066,58 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var percentageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var percentageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = newPercentageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } percentageDiscount = newPercentageDiscount.percentageDiscount isInvoiceLevel = newPercentageDiscount.isInvoiceLevel additionalProperties = newPercentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun percentageDiscount(percentageDiscount: Double) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount } /** @@ -28399,15 +37125,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28439,7 +37165,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(percentageDiscount) { "`percentageDiscount` is required but was not set" }, @@ -28522,34 +37248,74 @@ constructor( class NewUsageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("usage_discount") private val usageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("usage_discount") fun usageDiscount(): Double = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewUsageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + usageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28559,46 +37325,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var usageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var usageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newUsageDiscount: NewUsageDiscount) = apply { adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = newUsageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } usageDiscount = newUsageDiscount.usageDiscount isInvoiceLevel = newUsageDiscount.isInvoiceLevel additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun usageDiscount(usageDiscount: Double) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount } /** @@ -28606,15 +37383,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28646,7 +37423,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(usageDiscount) { "`usageDiscount` is required but was not set" }, @@ -28729,34 +37506,74 @@ constructor( class NewAmountDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("amount_discount") private val amountDiscount: String, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType - @JsonProperty("amount_discount") fun amountDiscount(): String = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAmountDiscount = apply { + if (!validated) { + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28766,46 +37583,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var amountDiscount: String? = null - private var appliesToPriceIds: MutableList? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newAmountDiscount: NewAmountDiscount) = apply { adjustmentType = newAmountDiscount.adjustmentType amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = newAmountDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = newAmountDiscount.isInvoiceLevel additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } - fun amountDiscount(amountDiscount: String) = apply { + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -28813,15 +37641,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -28856,7 +37684,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, isInvoiceLevel, additionalProperties.toImmutable(), ) @@ -28936,38 +37764,84 @@ constructor( class NewMinimum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMinimum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + itemId() + minimumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28977,51 +37851,64 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var itemId: String? = null - private var minimumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMinimum: NewMinimum) = apply { adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } itemId = newMinimum.itemId minimumAmount = newMinimum.minimumAmount isInvoiceLevel = newMinimum.isInvoiceLevel additionalProperties = newMinimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun minimumAmount(minimumAmount: String) = apply { - this.minimumAmount = minimumAmount - } + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** @@ -29029,15 +37916,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -29069,7 +37956,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" @@ -29153,34 +38040,74 @@ constructor( class NewMaximum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("maximum_amount") private val maximumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("maximum_amount") fun maximumAmount(): String = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMaximum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + maximumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29190,46 +38117,56 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var maximumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMaximum: NewMaximum) = apply { adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = newMaximum.maximumAmount isInvoiceLevel = newMaximum.isInvoiceLevel additionalProperties = newMaximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun maximumAmount(maximumAmount: String) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** @@ -29237,15 +38174,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -29277,7 +38214,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, @@ -29370,6 +38307,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -29395,6 +38334,15 @@ constructor( } } + fun validate(): StartDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown StartDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29483,6 +38431,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -29508,6 +38458,15 @@ constructor( } } + fun validate(): EndDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown EndDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29605,18 +38564,63 @@ constructor( class Edit @JsonCreator private constructor( - @JsonProperty("price_interval_id") private val priceIntervalId: String, - @JsonProperty("billing_cycle_day") private val billingCycleDay: Long?, - @JsonProperty("end_date") private val endDate: EndDate?, + @JsonProperty("price_interval_id") + @ExcludeMissing + private val priceIntervalId: JsonField = JsonMissing.of(), + @JsonProperty("billing_cycle_day") + @ExcludeMissing + private val billingCycleDay: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), @JsonProperty("fixed_fee_quantity_transitions") - private val fixedFeeQuantityTransitions: List?, - @JsonProperty("start_date") private val startDate: StartDate?, + @ExcludeMissing + private val fixedFeeQuantityTransitions: JsonField> = + JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the price interval to edit. */ - @JsonProperty("price_interval_id") fun priceIntervalId(): String = priceIntervalId + fun priceIntervalId(): String = priceIntervalId.getRequired("price_interval_id") + + /** + * The updated billing cycle day for this price interval. If not specified, the billing + * cycle day will not be updated. Note that overlapping price intervals must have the same + * billing cycle day. + */ + fun billingCycleDay(): Optional = + Optional.ofNullable(billingCycleDay.getNullable("billing_cycle_day")) + + /** + * The updated end date of this price interval. If not specified, the start date will not be + * updated. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** + * A list of fixed fee quantity transitions to use for this price interval. Note that this + * list will overwrite all existing fixed fee quantity transitions on the price interval. + */ + fun fixedFeeQuantityTransitions(): Optional> = + Optional.ofNullable( + fixedFeeQuantityTransitions.getNullable("fixed_fee_quantity_transitions") + ) + + /** + * The updated start date of this price interval. If not specified, the start date will not + * be updated. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + + /** The id of the price interval to edit. */ + @JsonProperty("price_interval_id") + @ExcludeMissing + fun _priceIntervalId(): JsonField = priceIntervalId /** * The updated billing cycle day for this price interval. If not specified, the billing @@ -29624,33 +38628,49 @@ constructor( * billing cycle day. */ @JsonProperty("billing_cycle_day") - fun billingCycleDay(): Optional = Optional.ofNullable(billingCycleDay) + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The updated end date of this price interval. If not specified, the start date will not be * updated. */ - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** * A list of fixed fee quantity transitions to use for this price interval. Note that this * list will overwrite all existing fixed fee quantity transitions on the price interval. */ @JsonProperty("fixed_fee_quantity_transitions") - fun fixedFeeQuantityTransitions(): Optional> = - Optional.ofNullable(fixedFeeQuantityTransitions) + @ExcludeMissing + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The updated start date of this price interval. If not specified, the start date will not * be updated. */ @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Edit = apply { + if (!validated) { + priceIntervalId() + billingCycleDay() + endDate() + fixedFeeQuantityTransitions().map { it.forEach { it.validate() } } + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29660,11 +38680,13 @@ constructor( class Builder { - private var priceIntervalId: String? = null - private var billingCycleDay: Long? = null - private var endDate: EndDate? = null - private var fixedFeeQuantityTransitions: MutableList? = null - private var startDate: StartDate? = null + private var priceIntervalId: JsonField? = null + private var billingCycleDay: JsonField = JsonMissing.of() + private var endDate: JsonField = JsonMissing.of() + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29672,13 +38694,18 @@ constructor( priceIntervalId = edit.priceIntervalId billingCycleDay = edit.billingCycleDay endDate = edit.endDate - fixedFeeQuantityTransitions = edit.fixedFeeQuantityTransitions?.toMutableList() + fixedFeeQuantityTransitions = + edit.fixedFeeQuantityTransitions.map { it.toMutableList() } startDate = edit.startDate additionalProperties = edit.additionalProperties.toMutableMap() } /** The id of the price interval to edit. */ - fun priceIntervalId(priceIntervalId: String) = apply { + fun priceIntervalId(priceIntervalId: String) = + priceIntervalId(JsonField.of(priceIntervalId)) + + /** The id of the price interval to edit. */ + fun priceIntervalId(priceIntervalId: JsonField) = apply { this.priceIntervalId = priceIntervalId } @@ -29687,9 +38714,8 @@ constructor( * cycle day will not be updated. Note that overlapping price intervals must have the * same billing cycle day. */ - fun billingCycleDay(billingCycleDay: Long?) = apply { - this.billingCycleDay = billingCycleDay - } + fun billingCycleDay(billingCycleDay: Long?) = + billingCycleDay(JsonField.ofNullable(billingCycleDay)) /** * The updated billing cycle day for this price interval. If not specified, the billing @@ -29707,11 +38733,20 @@ constructor( fun billingCycleDay(billingCycleDay: Optional) = billingCycleDay(billingCycleDay.orElse(null) as Long?) + /** + * The updated billing cycle day for this price interval. If not specified, the billing + * cycle day will not be updated. Note that overlapping price intervals must have the + * same billing cycle day. + */ + fun billingCycleDay(billingCycleDay: JsonField) = apply { + this.billingCycleDay = billingCycleDay + } + /** * The updated end date of this price interval. If not specified, the start date will * not be updated. */ - fun endDate(endDate: EndDate?) = apply { this.endDate = endDate } + fun endDate(endDate: EndDate?) = endDate(JsonField.ofNullable(endDate)) /** * The updated end date of this price interval. If not specified, the start date will @@ -29719,13 +38754,16 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - fun endDate(dateTime: OffsetDateTime) = apply { - this.endDate = EndDate.ofDateTime(dateTime) - } + /** + * The updated end date of this price interval. If not specified, the start date will + * not be updated. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.endDate = EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun endDate(dateTime: OffsetDateTime) = endDate(EndDate.ofDateTime(dateTime)) + + fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + endDate(EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) /** * A list of fixed fee quantity transitions to use for this price interval. Note that @@ -29734,9 +38772,7 @@ constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: List? - ) = apply { - this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions?.toMutableList() - } + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) /** * A list of fixed fee quantity transitions to use for this price interval. Note that @@ -29747,6 +38783,18 @@ constructor( fixedFeeQuantityTransitions: Optional> ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) + /** + * A list of fixed fee quantity transitions to use for this price interval. Note that + * this list will overwrite all existing fixed fee quantity transitions on the price + * interval. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: JsonField> + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + /** * A list of fixed fee quantity transitions to use for this price interval. Note that * this list will overwrite all existing fixed fee quantity transitions on the price @@ -29756,8 +38804,14 @@ constructor( fixedFeeQuantityTransition: FixedFeeQuantityTransition ) = apply { fixedFeeQuantityTransitions = - (fixedFeeQuantityTransitions ?: mutableListOf()).apply { - add(fixedFeeQuantityTransition) + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) } } @@ -29765,21 +38819,18 @@ constructor( * The updated start date of this price interval. If not specified, the start date will * not be updated. */ - fun startDate(startDate: StartDate?) = apply { this.startDate = startDate } + fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) /** * The updated start date of this price interval. If not specified, the start date will * not be updated. */ - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - fun startDate(dateTime: OffsetDateTime) = apply { - this.startDate = StartDate.ofDateTime(dateTime) - } + fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) - fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.startDate = StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + startDate(StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -29807,7 +38858,7 @@ constructor( }, billingCycleDay, endDate, - fixedFeeQuantityTransitions?.toImmutable(), + (fixedFeeQuantityTransitions ?: JsonMissing.of()).map { it.toImmutable() }, startDate, additionalProperties.toImmutable(), ) @@ -29826,6 +38877,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -29851,6 +38904,15 @@ constructor( } } + fun validate(): EndDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown EndDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -29930,22 +38992,44 @@ constructor( class FixedFeeQuantityTransition @JsonCreator private constructor( - @JsonProperty("effective_date") private val effectiveDate: OffsetDateTime, - @JsonProperty("quantity") private val quantity: Long, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The date that the fixed fee quantity transition should take effect. */ - @JsonProperty("effective_date") fun effectiveDate(): OffsetDateTime = effectiveDate + fun effectiveDate(): OffsetDateTime = effectiveDate.getRequired("effective_date") + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(): Long = quantity.getRequired("quantity") + + /** The date that the fixed fee quantity transition should take effect. */ + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate /** The quantity of the fixed fee quantity transition. */ - @JsonProperty("quantity") fun quantity(): Long = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): FixedFeeQuantityTransition = apply { + if (!validated) { + effectiveDate() + quantity() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29955,8 +39039,8 @@ constructor( class Builder { - private var effectiveDate: OffsetDateTime? = null - private var quantity: Long? = null + private var effectiveDate: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29968,12 +39052,19 @@ constructor( } /** The date that the fixed fee quantity transition should take effect. */ - fun effectiveDate(effectiveDate: OffsetDateTime) = apply { + fun effectiveDate(effectiveDate: OffsetDateTime) = + effectiveDate(JsonField.of(effectiveDate)) + + /** The date that the fixed fee quantity transition should take effect. */ + fun effectiveDate(effectiveDate: JsonField) = apply { this.effectiveDate = effectiveDate } /** The quantity of the fixed fee quantity transition. */ - fun quantity(quantity: Long) = apply { this.quantity = quantity } + fun quantity(quantity: Long) = quantity(JsonField.of(quantity)) + + /** The quantity of the fixed fee quantity transition. */ + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -30038,6 +39129,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -30063,6 +39156,15 @@ constructor( } } + fun validate(): StartDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown StartDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30160,34 +39262,70 @@ constructor( class EditAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment_interval_id") private val adjustmentIntervalId: String, - @JsonProperty("end_date") private val endDate: EndDate?, - @JsonProperty("start_date") private val startDate: StartDate?, + @JsonProperty("adjustment_interval_id") + @ExcludeMissing + private val adjustmentIntervalId: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The id of the adjustment interval to edit. */ + fun adjustmentIntervalId(): String = + adjustmentIntervalId.getRequired("adjustment_interval_id") + + /** + * The updated end date of this adjustment interval. If not specified, the start date will + * not be updated. + */ + fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) + + /** + * The updated start date of this adjustment interval. If not specified, the start date will + * not be updated. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + /** The id of the adjustment interval to edit. */ @JsonProperty("adjustment_interval_id") - fun adjustmentIntervalId(): String = adjustmentIntervalId + @ExcludeMissing + fun _adjustmentIntervalId(): JsonField = adjustmentIntervalId /** * The updated end date of this adjustment interval. If not specified, the start date will * not be updated. */ - @JsonProperty("end_date") fun endDate(): Optional = Optional.ofNullable(endDate) + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate /** * The updated start date of this adjustment interval. If not specified, the start date will * not be updated. */ @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): EditAdjustment = apply { + if (!validated) { + adjustmentIntervalId() + endDate() + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30197,9 +39335,9 @@ constructor( class Builder { - private var adjustmentIntervalId: String? = null - private var endDate: EndDate? = null - private var startDate: StartDate? = null + private var adjustmentIntervalId: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -30211,7 +39349,11 @@ constructor( } /** The id of the adjustment interval to edit. */ - fun adjustmentIntervalId(adjustmentIntervalId: String) = apply { + fun adjustmentIntervalId(adjustmentIntervalId: String) = + adjustmentIntervalId(JsonField.of(adjustmentIntervalId)) + + /** The id of the adjustment interval to edit. */ + fun adjustmentIntervalId(adjustmentIntervalId: JsonField) = apply { this.adjustmentIntervalId = adjustmentIntervalId } @@ -30219,7 +39361,7 @@ constructor( * The updated end date of this adjustment interval. If not specified, the start date * will not be updated. */ - fun endDate(endDate: EndDate?) = apply { this.endDate = endDate } + fun endDate(endDate: EndDate?) = endDate(JsonField.ofNullable(endDate)) /** * The updated end date of this adjustment interval. If not specified, the start date @@ -30227,33 +39369,33 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) - fun endDate(dateTime: OffsetDateTime) = apply { - this.endDate = EndDate.ofDateTime(dateTime) - } + /** + * The updated end date of this adjustment interval. If not specified, the start date + * will not be updated. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } - fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.endDate = EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun endDate(dateTime: OffsetDateTime) = endDate(EndDate.ofDateTime(dateTime)) + + fun endDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + endDate(EndDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) /** * The updated start date of this adjustment interval. If not specified, the start date * will not be updated. */ - fun startDate(startDate: StartDate?) = apply { this.startDate = startDate } + fun startDate(startDate: StartDate) = startDate(JsonField.of(startDate)) /** * The updated start date of this adjustment interval. If not specified, the start date * will not be updated. */ - fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + fun startDate(startDate: JsonField) = apply { this.startDate = startDate } - fun startDate(dateTime: OffsetDateTime) = apply { - this.startDate = StartDate.ofDateTime(dateTime) - } + fun startDate(dateTime: OffsetDateTime) = startDate(StartDate.ofDateTime(dateTime)) - fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = apply { - this.startDate = StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate) - } + fun startDate(billingCycleRelativeDate: BillingCycleRelativeDate) = + startDate(StartDate.ofBillingCycleRelativeDate(billingCycleRelativeDate)) fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -30298,6 +39440,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -30323,6 +39467,15 @@ constructor( } } + fun validate(): EndDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown EndDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -30411,6 +39564,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun dateTime(): Optional = Optional.ofNullable(dateTime) fun billingCycleRelativeDate(): Optional = @@ -30436,6 +39591,15 @@ constructor( } } + fun validate(): StartDate = apply { + if (!validated) { + if (dateTime == null && billingCycleRelativeDate == null) { + throw OrbInvalidDataException("Unknown StartDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt index 4c628942..91e00699 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionPriceIntervalsResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -453,7 +473,10 @@ private constructor( apply { id = subscriptionPriceIntervalsResponse.id activePlanPhaseOrder = subscriptionPriceIntervalsResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionPriceIntervalsResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionPriceIntervalsResponse.adjustmentIntervals.map { + it.toMutableList() + } autoCollection = subscriptionPriceIntervalsResponse.autoCollection billingCycleAnchorConfiguration = subscriptionPriceIntervalsResponse.billingCycleAnchorConfiguration @@ -465,17 +488,23 @@ private constructor( subscriptionPriceIntervalsResponse.currentBillingPeriodStartDate customer = subscriptionPriceIntervalsResponse.customer defaultInvoiceMemo = subscriptionPriceIntervalsResponse.defaultInvoiceMemo - discountIntervals = subscriptionPriceIntervalsResponse.discountIntervals + discountIntervals = + subscriptionPriceIntervalsResponse.discountIntervals.map { it.toMutableList() } endDate = subscriptionPriceIntervalsResponse.endDate fixedFeeQuantitySchedule = - subscriptionPriceIntervalsResponse.fixedFeeQuantitySchedule + subscriptionPriceIntervalsResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionPriceIntervalsResponse.invoicingThreshold - maximumIntervals = subscriptionPriceIntervalsResponse.maximumIntervals + maximumIntervals = + subscriptionPriceIntervalsResponse.maximumIntervals.map { it.toMutableList() } metadata = subscriptionPriceIntervalsResponse.metadata - minimumIntervals = subscriptionPriceIntervalsResponse.minimumIntervals + minimumIntervals = + subscriptionPriceIntervalsResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionPriceIntervalsResponse.netTerms plan = subscriptionPriceIntervalsResponse.plan - priceIntervals = subscriptionPriceIntervalsResponse.priceIntervals + priceIntervals = + subscriptionPriceIntervalsResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionPriceIntervalsResponse.redeemedCoupon startDate = subscriptionPriceIntervalsResponse.startDate status = subscriptionPriceIntervalsResponse.status @@ -488,9 +517,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -503,15 +541,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -557,8 +626,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -575,8 +652,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -631,8 +716,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -648,11 +740,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } } + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } + } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -662,10 +771,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -677,7 +805,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -700,7 +842,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -739,11 +895,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -784,31 +957,55 @@ private constructor( fun build(): SubscriptionPriceIntervalsResponse = SubscriptionPriceIntervalsResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -849,20 +1046,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -890,18 +1093,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -917,6 +1121,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -924,11 +1143,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -962,11 +1199,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1269,11 +1509,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1281,12 +1521,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1294,15 +1534,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1332,13 +1572,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1346,7 +1586,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1386,7 +1627,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1404,9 +1659,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1414,7 +1678,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1443,13 +1710,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1581,16 +1859,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1598,7 +1876,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1606,15 +1884,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1644,13 +1922,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1658,7 +1936,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1684,7 +1965,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1717,9 +2012,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1727,7 +2031,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1756,13 +2063,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1893,16 +2211,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1910,21 +2228,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1954,20 +2274,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1993,7 +2314,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2011,9 +2346,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2021,7 +2365,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2065,13 +2412,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2208,16 +2566,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2225,24 +2583,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2273,21 +2633,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2313,7 +2674,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2352,9 +2727,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2362,7 +2746,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2391,14 +2778,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2529,16 +2927,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2546,21 +2944,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2590,20 +2990,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2628,7 +3029,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2661,9 +3076,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2671,7 +3095,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2700,13 +3127,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2839,19 +3277,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2877,7 +3315,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2912,7 +3350,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2924,7 +3375,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2953,7 +3417,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3205,25 +3669,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3252,19 +3724,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3287,7 +3761,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3297,9 +3785,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3308,7 +3811,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3345,12 +3851,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3473,25 +3987,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3520,18 +4040,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3546,7 +4070,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3556,9 +4094,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3567,7 +4120,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3617,12 +4173,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3748,26 +4312,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3796,18 +4368,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3821,7 +4395,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3831,9 +4419,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3842,7 +4445,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3894,12 +4500,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4003,13 +4617,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4036,10 +4654,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4051,7 +4669,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4090,10 +4710,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4163,24 +4783,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4208,17 +4834,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4231,7 +4858,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4241,11 +4882,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4293,11 +4952,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4447,24 +5112,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4492,17 +5163,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4515,7 +5187,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4525,11 +5211,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4577,11 +5281,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4916,10 +5626,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4928,7 +5640,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4937,13 +5649,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4951,7 +5666,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5181,13 +5897,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5218,15 +5936,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5236,7 +5955,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5260,8 +5980,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5277,8 +6005,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5293,7 +6030,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5306,8 +6049,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5315,7 +6066,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5777,6 +6550,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5812,14 +6650,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5847,11 +6694,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5877,9 +6726,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5930,9 +6779,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5997,11 +6848,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6027,9 +6882,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6044,7 +6899,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6075,9 +6932,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6177,7 +7034,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6201,7 +7060,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6210,7 +7069,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6233,7 +7094,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt index 90a5609a..d305ac54 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -31,6 +32,164 @@ import java.util.Objects import java.util.Optional import kotlin.jvm.optionals.getOrNull +/** + * This endpoint can be used to change an existing subscription's plan. It returns the serialized + * updated subscription object. + * + * The body parameter `change_option` determines when the plan change occurrs. Orb supports three + * options: + * - `end_of_subscription_term`: changes the plan at the end of the existing plan's term. + * - Issuing this plan change request for a monthly subscription will keep the existing plan + * active until the start of the subsequent month. Issuing this plan change request for a + * yearly subscription will keep the existing plan active for the full year. Charges incurred + * in the remaining period will be invoiced as normal. + * - Example: The plan is billed monthly on the 1st of the month, the request is made on January + * 15th, so the plan will be changed on February 1st, and invoice will be issued on February + * 1st for the last month of the original plan. + * - `immediate`: changes the plan immediately. + * - Subscriptions that have their plan changed with this option will move to the new plan + * immediately, and be invoiced immediately. + * - This invoice will include any usage fees incurred in the billing period up to the change, + * along with any prorated recurring fees for the billing period, if applicable. + * - Example: The plan is billed monthly on the 1st of the month, the request is made on January + * 15th, so the plan will be changed on January 15th, and an invoice will be issued for the + * partial month, from January 1 to January 15, on the original plan. + * - `requested_date`: changes the plan on the requested date (`change_date`). + * - If no timezone is provided, the customer's timezone is used. The `change_date` body + * parameter is required if this option is chosen. + * - Example: The plan is billed monthly on the 1st of the month, the request is made on January + * 15th, with a requested `change_date` of February 15th, so the plan will be changed on + * February 15th, and invoices will be issued on February 1st and February 15th. + * + * Note that one of `plan_id` or `external_plan_id` is required in the request body for this + * operation. + * + * ## Customize your customer's subscriptions + * + * Prices and adjustments in a plan can be added, removed, or replaced on the subscription when you + * schedule the plan change. This is useful when a customer has prices that differ from the default + * prices for a specific plan. + * + * :::info This feature is only available for accounts that have migrated to Subscription Overrides + * Version 2. You can find your Subscription Overrides Version at the bottom of your + * [Plans page](https://app.withorb.com/plans) ::: + * + * ### Adding Prices + * + * To add prices, provide a list of objects with the key `add_prices`. An object in the list must + * specify an existing add-on price with a `price_id` or `external_price_id` field, or create a new + * add-on price by including an object with the key `price`, identical to what would be used in the + * request body for the [create price endpoint](../reference/create-price). See the + * [Price resource](../reference/price) for the specification of different price model + * configurations possible in this object. + * + * If the plan has phases, each object in the list must include a number with `plan_phase_order` key + * to indicate which phase the price should be added to. + * + * An object in the list can specify an optional `start_date` and optional `end_date`. This is + * equivalent to creating a price interval with the + * [add/edit price intervals endpoint](../reference/add-edit-price-intervals). If unspecified, the + * start or end date of the phase or subscription will be used. + * + * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or `discounts`. + * This will create adjustments which apply only to this price. + * + * Additionally, an object in the list can specify an optional `reference_id`. This ID can be used + * to reference this price when [adding an adjustment](#adding-adjustments) in the same API call. + * However the ID is _transient_ and cannot be used to refer to the price in future API calls. + * + * ### Removing Prices + * + * To remove prices, provide a list of objects with the key `remove_prices`. An object in the list + * must specify a plan price with either a `price_id` or `external_price_id` field. + * + * ### Replacing Prices + * + * To replace prices, provide a list of objects with the key `replace_prices`. An object in the list + * must specify a plan price to replace with the `replaces_price_id` key, and it must specify a + * price to replace it with by either referencing an existing add-on price with a `price_id` or + * `external_price_id` field, or by creating a new add-on price by including an object with the key + * `price`, identical to what would be used in the request body for the + * [create price endpoint](../reference/create-price). See the [Price resource](../reference/price) + * for the specification of different price model configurations possible in this object. + * + * For fixed fees, an object in the list can supply a `fixed_price_quantity` instead of a `price`, + * `price_id`, or `external_price_id` field. This will update only the quantity for the price, + * similar to the [Update price quantity](../reference/update-fixed-fee-quantity) endpoint. + * + * The replacement price will have the same phase, if applicable, and the same start and end dates + * as the price it replaces. + * + * An object in the list can specify an optional `minimum_amount`, `maximum_amount`, or `discounts`. + * This will create adjustments which apply only to this price. + * + * Additionally, an object in the list can specify an optional `reference_id`. This ID can be used + * to reference the replacement price when [adding an adjustment](#adding-adjustments) in the same + * API call. However the ID is _transient_ and cannot be used to refer to the price in future API + * calls. + * + * ### Adding adjustments + * + * To add adjustments, provide a list of objects with the key `add_adjustments`. An object in the + * list must include an object with the key `adjustment`, identical to the adjustment object in the + * [add/edit price intervals endpoint](../reference/add-edit-price-intervals). + * + * If the plan has phases, each object in the list must include a number with `plan_phase_order` key + * to indicate which phase the adjustment should be added to. + * + * An object in the list can specify an optional `start_date` and optional `end_date`. If + * unspecified, the start or end date of the phase or subscription will be used. + * + * ### Removing adjustments + * + * To remove adjustments, provide a list of objects with the key `remove_adjustments`. An object in + * the list must include a key, `adjustment_id`, with the ID of the adjustment to be removed. + * + * ### Replacing adjustments + * + * To replace adjustments, provide a list of objects with the key `replace_adjustments`. An object + * in the list must specify a plan adjustment to replace with the `replaces_adjustment_id` key, and + * it must specify an adjustment to replace it with by including an object with the key + * `adjustment`, identical to the adjustment object in the + * [add/edit price intervals endpoint](../reference/add-edit-price-intervals). + * + * The replacement adjustment will have the same phase, if applicable, and the same start and end + * dates as the adjustment it replaces. + * + * ## Price overrides (DEPRECATED) + * + * :::info Price overrides are being phased out in favor adding/removing/replacing prices. (See + * [Customize your customer's subscriptions](../reference/schedule-plan-change#customize-your-customers-subscriptions)) + * ::: + * + * Price overrides are used to update some or all prices in a plan for the specific subscription + * being created. This is useful when a new customer has negotiated a rate that is unique to the + * customer. + * + * To override prices, provide a list of objects with the key `price_overrides`. The price object in + * the list of overrides is expected to contain the existing price id, the `model_type` and + * configuration. (See the [Price resource](../reference/price) for the specification of different + * price model configurations.) The numerical values can be updated, but the billable metric, + * cadence, type, and name of a price can not be overridden. + * + * ### Maximums, and minimums + * + * Price overrides are used to update some or all prices in the target plan. Minimums and maximums, + * much like price overrides, can be useful when a new customer has negotiated a new or different + * minimum or maximum spend cap than the default for the plan. The request format for maximums and + * minimums is the same as those in [subscription creation](create-subscription). + * + * ## Scheduling multiple plan changes + * + * When scheduling multiple plan changes with the same date, the latest plan change on that day + * takes effect. + * + * ## Prorations for in-advance fees + * + * By default, Orb calculates the prorated difference in any fixed fees when making a plan change, + * adjusting the customer balance as needed. For details on this behavior, see + * [Modifying subscriptions](../guides/product-catalog/modifying-subscriptions.md#prorations-for-in-advance-fees). + */ class SubscriptionSchedulePlanChangeParams constructor( private val subscriptionId: String, @@ -174,12 +333,146 @@ constructor( */ fun trialDurationDays(): Optional = body.trialDurationDays() - fun _additionalHeaders(): Headers = additionalHeaders + fun _changeOption(): JsonField = body._changeOption() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Additional adjustments to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun _addAdjustments(): JsonField> = body._addAdjustments() + + /** + * Additional prices to be added to the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun _addPrices(): JsonField> = body._addPrices() + + /** + * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned with + * the plan change's effective date. + */ + fun _alignBillingWithPlanChangeDate(): JsonField = + body._alignBillingWithPlanChangeDate() + + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. If not specified, this defaults to the behavior + * configured for this customer. + */ + fun _autoCollection(): JsonField = body._autoCollection() + + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle alignment. + */ + fun _billingCycleAlignment(): JsonField = body._billingCycleAlignment() + + fun _billingCycleAnchorConfiguration(): JsonField = + body._billingCycleAnchorConfiguration() + + /** + * The date that the plan change should take effect. This parameter can only be passed if the + * `change_option` is `requested_date`. + */ + fun _changeDate(): JsonField = body._changeDate() + + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by its + * redemption code, or cannot be redeemed, an error response will be returned and the + * subscription creation or plan change will not be scheduled. + */ + fun _couponRedemptionCode(): JsonField = body._couponRedemptionCode() + + fun _creditsOverageRate(): JsonField = body._creditsOverageRate() + + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun _defaultInvoiceMemo(): JsonField = body._defaultInvoiceMemo() + + /** + * The external_plan_id of the plan that the given subscription should be switched to. Note that + * either this property or `plan_id` must be specified. + */ + fun _externalPlanId(): JsonField = body._externalPlanId() + + /** + * An additional filter to apply to usage queries. This filter must be expressed as a boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If null, + * usage queries will not include any additional filter. + */ + fun _filter(): JsonField = body._filter() + + /** The phase of the plan to start with */ + fun _initialPhaseOrder(): JsonField = body._initialPhaseOrder() + + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued for + * the subscription. If not specified, invoices will only be issued at the end of the billing + * period. + */ + fun _invoicingThreshold(): JsonField = body._invoicingThreshold() + + /** + * The net terms determines the difference between the invoice date and the issue date for the + * invoice. If you intend the invoice to be due on issue, set this to 0. If not provided, this + * defaults to the value specified in the plan. + */ + fun _netTerms(): JsonField = body._netTerms() + + fun _perCreditOverageAmount(): JsonField = body._perCreditOverageAmount() + + /** + * The plan that the given subscription should be switched to. Note that either this property or + * `external_plan_id` must be specified. + */ + fun _planId(): JsonField = body._planId() + + /** + * Specifies which version of the plan to change to. If null, the default version will be used. + */ + fun _planVersionNumber(): JsonField = body._planVersionNumber() + + /** Optionally provide a list of overrides for prices on the plan */ + fun _priceOverrides(): JsonField> = body._priceOverrides() + + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun _removeAdjustments(): JsonField> = body._removeAdjustments() + + /** + * Plan prices to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun _removePrices(): JsonField> = body._removePrices() + + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun _replaceAdjustments(): JsonField> = body._replaceAdjustments() + + /** + * Plan prices to be replaced with additional prices on the subscription. (Only available for + * accounts that have migrated off of legacy subscription overrides) + */ + fun _replacePrices(): JsonField> = body._replacePrices() + + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun _trialDurationDays(): JsonField = body._trialDurationDays() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionSchedulePlanChangeBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -197,62 +490,273 @@ constructor( class SubscriptionSchedulePlanChangeBody @JsonCreator internal constructor( - @JsonProperty("change_option") private val changeOption: ChangeOption, - @JsonProperty("add_adjustments") private val addAdjustments: List?, - @JsonProperty("add_prices") private val addPrices: List?, + @JsonProperty("change_option") + @ExcludeMissing + private val changeOption: JsonField = JsonMissing.of(), + @JsonProperty("add_adjustments") + @ExcludeMissing + private val addAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("add_prices") + @ExcludeMissing + private val addPrices: JsonField> = JsonMissing.of(), @JsonProperty("align_billing_with_plan_change_date") - private val alignBillingWithPlanChangeDate: Boolean?, - @JsonProperty("auto_collection") private val autoCollection: Boolean?, + @ExcludeMissing + private val alignBillingWithPlanChangeDate: JsonField = JsonMissing.of(), + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_alignment") - private val billingCycleAlignment: BillingCycleAlignment?, + @ExcludeMissing + private val billingCycleAlignment: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_anchor_configuration") - private val billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration?, - @JsonProperty("change_date") private val changeDate: OffsetDateTime?, - @JsonProperty("coupon_redemption_code") private val couponRedemptionCode: String?, - @JsonProperty("credits_overage_rate") private val creditsOverageRate: Double?, - @JsonProperty("default_invoice_memo") private val defaultInvoiceMemo: String?, - @JsonProperty("external_plan_id") private val externalPlanId: String?, - @JsonProperty("filter") private val filter: String?, - @JsonProperty("initial_phase_order") private val initialPhaseOrder: Long?, - @JsonProperty("invoicing_threshold") private val invoicingThreshold: String?, - @JsonProperty("net_terms") private val netTerms: Long?, - @JsonProperty("per_credit_overage_amount") private val perCreditOverageAmount: Double?, - @JsonProperty("plan_id") private val planId: String?, - @JsonProperty("plan_version_number") private val planVersionNumber: Long?, - @JsonProperty("price_overrides") private val priceOverrides: List?, - @JsonProperty("remove_adjustments") private val removeAdjustments: List?, - @JsonProperty("remove_prices") private val removePrices: List?, + @ExcludeMissing + private val billingCycleAnchorConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("change_date") + @ExcludeMissing + private val changeDate: JsonField = JsonMissing.of(), + @JsonProperty("coupon_redemption_code") + @ExcludeMissing + private val couponRedemptionCode: JsonField = JsonMissing.of(), + @JsonProperty("credits_overage_rate") + @ExcludeMissing + private val creditsOverageRate: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("external_plan_id") + @ExcludeMissing + private val externalPlanId: JsonField = JsonMissing.of(), + @JsonProperty("filter") + @ExcludeMissing + private val filter: JsonField = JsonMissing.of(), + @JsonProperty("initial_phase_order") + @ExcludeMissing + private val initialPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + private val invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), + @JsonProperty("per_credit_overage_amount") + @ExcludeMissing + private val perCreditOverageAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_id") + @ExcludeMissing + private val planId: JsonField = JsonMissing.of(), + @JsonProperty("plan_version_number") + @ExcludeMissing + private val planVersionNumber: JsonField = JsonMissing.of(), + @JsonProperty("price_overrides") + @ExcludeMissing + private val priceOverrides: JsonField> = JsonMissing.of(), + @JsonProperty("remove_adjustments") + @ExcludeMissing + private val removeAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("remove_prices") + @ExcludeMissing + private val removePrices: JsonField> = JsonMissing.of(), @JsonProperty("replace_adjustments") - private val replaceAdjustments: List?, - @JsonProperty("replace_prices") private val replacePrices: List?, - @JsonProperty("trial_duration_days") private val trialDurationDays: Long?, + @ExcludeMissing + private val replaceAdjustments: JsonField> = JsonMissing.of(), + @JsonProperty("replace_prices") + @ExcludeMissing + private val replacePrices: JsonField> = JsonMissing.of(), + @JsonProperty("trial_duration_days") + @ExcludeMissing + private val trialDurationDays: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("change_option") fun changeOption(): ChangeOption = changeOption + fun changeOption(): ChangeOption = changeOption.getRequired("change_option") + + /** + * Additional adjustments to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun addAdjustments(): Optional> = + Optional.ofNullable(addAdjustments.getNullable("add_adjustments")) + + /** + * Additional prices to be added to the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun addPrices(): Optional> = + Optional.ofNullable(addPrices.getNullable("add_prices")) + + /** + * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned + * with the plan change's effective date. + */ + fun alignBillingWithPlanChangeDate(): Optional = + Optional.ofNullable( + alignBillingWithPlanChangeDate.getNullable("align_billing_with_plan_change_date") + ) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. If not specified, this defaults to the + * behavior configured for this customer. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle + * alignment. + */ + fun billingCycleAlignment(): Optional = + Optional.ofNullable(billingCycleAlignment.getNullable("billing_cycle_alignment")) + + fun billingCycleAnchorConfiguration(): Optional = + Optional.ofNullable( + billingCycleAnchorConfiguration.getNullable("billing_cycle_anchor_configuration") + ) + + /** + * The date that the plan change should take effect. This parameter can only be passed if + * the `change_option` is `requested_date`. + */ + fun changeDate(): Optional = + Optional.ofNullable(changeDate.getNullable("change_date")) + + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by its + * redemption code, or cannot be redeemed, an error response will be returned and the + * subscription creation or plan change will not be scheduled. + */ + fun couponRedemptionCode(): Optional = + Optional.ofNullable(couponRedemptionCode.getNullable("coupon_redemption_code")) + + fun creditsOverageRate(): Optional = + Optional.ofNullable(creditsOverageRate.getNullable("credits_overage_rate")) + + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + /** + * The external_plan_id of the plan that the given subscription should be switched to. Note + * that either this property or `plan_id` must be specified. + */ + fun externalPlanId(): Optional = + Optional.ofNullable(externalPlanId.getNullable("external_plan_id")) + + /** + * An additional filter to apply to usage queries. This filter must be expressed as a + * boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If + * null, usage queries will not include any additional filter. + */ + fun filter(): Optional = Optional.ofNullable(filter.getNullable("filter")) + + /** The phase of the plan to start with */ + fun initialPhaseOrder(): Optional = + Optional.ofNullable(initialPhaseOrder.getNullable("initial_phase_order")) + + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued + * for the subscription. If not specified, invoices will only be issued at the end of the + * billing period. + */ + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. If not + * provided, this defaults to the value specified in the plan. + */ + fun netTerms(): Optional = Optional.ofNullable(netTerms.getNullable("net_terms")) + + fun perCreditOverageAmount(): Optional = + Optional.ofNullable(perCreditOverageAmount.getNullable("per_credit_overage_amount")) + + /** + * The plan that the given subscription should be switched to. Note that either this + * property or `external_plan_id` must be specified. + */ + fun planId(): Optional = Optional.ofNullable(planId.getNullable("plan_id")) + + /** + * Specifies which version of the plan to change to. If null, the default version will be + * used. + */ + fun planVersionNumber(): Optional = + Optional.ofNullable(planVersionNumber.getNullable("plan_version_number")) + + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(): Optional> = + Optional.ofNullable(priceOverrides.getNullable("price_overrides")) + + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun removeAdjustments(): Optional> = + Optional.ofNullable(removeAdjustments.getNullable("remove_adjustments")) + + /** + * Plan prices to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun removePrices(): Optional> = + Optional.ofNullable(removePrices.getNullable("remove_prices")) + + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun replaceAdjustments(): Optional> = + Optional.ofNullable(replaceAdjustments.getNullable("replace_adjustments")) + + /** + * Plan prices to be replaced with additional prices on the subscription. (Only available + * for accounts that have migrated off of legacy subscription overrides) + */ + fun replacePrices(): Optional> = + Optional.ofNullable(replacePrices.getNullable("replace_prices")) + + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun trialDurationDays(): Optional = + Optional.ofNullable(trialDurationDays.getNullable("trial_duration_days")) + + @JsonProperty("change_option") + @ExcludeMissing + fun _changeOption(): JsonField = changeOption /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ @JsonProperty("add_adjustments") - fun addAdjustments(): Optional> = Optional.ofNullable(addAdjustments) + @ExcludeMissing + fun _addAdjustments(): JsonField> = addAdjustments /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ @JsonProperty("add_prices") - fun addPrices(): Optional> = Optional.ofNullable(addPrices) + @ExcludeMissing + fun _addPrices(): JsonField> = addPrices /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned * with the plan change's effective date. */ @JsonProperty("align_billing_with_plan_change_date") - fun alignBillingWithPlanChangeDate(): Optional = - Optional.ofNullable(alignBillingWithPlanChangeDate) + @ExcludeMissing + fun _alignBillingWithPlanChangeDate(): JsonField = alignBillingWithPlanChangeDate /** * Determines whether issued invoices for this subscription will automatically be charged @@ -260,7 +764,8 @@ constructor( * behavior configured for this customer. */ @JsonProperty("auto_collection") - fun autoCollection(): Optional = Optional.ofNullable(autoCollection) + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** * Reset billing periods to be aligned with the plan change's effective date or start of the @@ -268,19 +773,21 @@ constructor( * alignment. */ @JsonProperty("billing_cycle_alignment") - fun billingCycleAlignment(): Optional = - Optional.ofNullable(billingCycleAlignment) + @ExcludeMissing + fun _billingCycleAlignment(): JsonField = billingCycleAlignment @JsonProperty("billing_cycle_anchor_configuration") - fun billingCycleAnchorConfiguration(): Optional = - Optional.ofNullable(billingCycleAnchorConfiguration) + @ExcludeMissing + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The date that the plan change should take effect. This parameter can only be passed if * the `change_option` is `requested_date`. */ @JsonProperty("change_date") - fun changeDate(): Optional = Optional.ofNullable(changeDate) + @ExcludeMissing + fun _changeDate(): JsonField = changeDate /** * Redemption code to be used for this subscription. If the coupon cannot be found by its @@ -288,24 +795,28 @@ constructor( * subscription creation or plan change will not be scheduled. */ @JsonProperty("coupon_redemption_code") - fun couponRedemptionCode(): Optional = Optional.ofNullable(couponRedemptionCode) + @ExcludeMissing + fun _couponRedemptionCode(): JsonField = couponRedemptionCode @JsonProperty("credits_overage_rate") - fun creditsOverageRate(): Optional = Optional.ofNullable(creditsOverageRate) + @ExcludeMissing + fun _creditsOverageRate(): JsonField = creditsOverageRate /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. */ @JsonProperty("default_invoice_memo") - fun defaultInvoiceMemo(): Optional = Optional.ofNullable(defaultInvoiceMemo) + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** * The external_plan_id of the plan that the given subscription should be switched to. Note * that either this property or `plan_id` must be specified. */ @JsonProperty("external_plan_id") - fun externalPlanId(): Optional = Optional.ofNullable(externalPlanId) + @ExcludeMissing + fun _externalPlanId(): JsonField = externalPlanId /** * An additional filter to apply to usage queries. This filter must be expressed as a @@ -313,11 +824,12 @@ constructor( * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If * null, usage queries will not include any additional filter. */ - @JsonProperty("filter") fun filter(): Optional = Optional.ofNullable(filter) + @JsonProperty("filter") @ExcludeMissing fun _filter(): JsonField = filter /** The phase of the plan to start with */ @JsonProperty("initial_phase_order") - fun initialPhaseOrder(): Optional = Optional.ofNullable(initialPhaseOrder) + @ExcludeMissing + fun _initialPhaseOrder(): JsonField = initialPhaseOrder /** * When this subscription's accrued usage reaches this threshold, an invoice will be issued @@ -325,76 +837,116 @@ constructor( * billing period. */ @JsonProperty("invoicing_threshold") - fun invoicingThreshold(): Optional = Optional.ofNullable(invoicingThreshold) + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. If not * provided, this defaults to the value specified in the plan. */ - @JsonProperty("net_terms") fun netTerms(): Optional = Optional.ofNullable(netTerms) + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms @JsonProperty("per_credit_overage_amount") - fun perCreditOverageAmount(): Optional = Optional.ofNullable(perCreditOverageAmount) + @ExcludeMissing + fun _perCreditOverageAmount(): JsonField = perCreditOverageAmount /** * The plan that the given subscription should be switched to. Note that either this * property or `external_plan_id` must be specified. */ - @JsonProperty("plan_id") fun planId(): Optional = Optional.ofNullable(planId) + @JsonProperty("plan_id") @ExcludeMissing fun _planId(): JsonField = planId /** * Specifies which version of the plan to change to. If null, the default version will be * used. */ @JsonProperty("plan_version_number") - fun planVersionNumber(): Optional = Optional.ofNullable(planVersionNumber) + @ExcludeMissing + fun _planVersionNumber(): JsonField = planVersionNumber /** Optionally provide a list of overrides for prices on the plan */ @JsonProperty("price_overrides") - fun priceOverrides(): Optional> = Optional.ofNullable(priceOverrides) + @ExcludeMissing + fun _priceOverrides(): JsonField> = priceOverrides /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ @JsonProperty("remove_adjustments") - fun removeAdjustments(): Optional> = - Optional.ofNullable(removeAdjustments) + @ExcludeMissing + fun _removeAdjustments(): JsonField> = removeAdjustments /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) */ @JsonProperty("remove_prices") - fun removePrices(): Optional> = Optional.ofNullable(removePrices) + @ExcludeMissing + fun _removePrices(): JsonField> = removePrices /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ @JsonProperty("replace_adjustments") - fun replaceAdjustments(): Optional> = - Optional.ofNullable(replaceAdjustments) + @ExcludeMissing + fun _replaceAdjustments(): JsonField> = replaceAdjustments /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) */ @JsonProperty("replace_prices") - fun replacePrices(): Optional> = Optional.ofNullable(replacePrices) + @ExcludeMissing + fun _replacePrices(): JsonField> = replacePrices /** * The duration of the trial period in days. If not provided, this defaults to the value * specified in the plan. If `0` is provided, the trial on the plan will be skipped. */ @JsonProperty("trial_duration_days") - fun trialDurationDays(): Optional = Optional.ofNullable(trialDurationDays) + @ExcludeMissing + fun _trialDurationDays(): JsonField = trialDurationDays @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionSchedulePlanChangeBody = apply { + if (!validated) { + changeOption() + addAdjustments().map { it.forEach { it.validate() } } + addPrices().map { it.forEach { it.validate() } } + alignBillingWithPlanChangeDate() + autoCollection() + billingCycleAlignment() + billingCycleAnchorConfiguration().map { it.validate() } + changeDate() + couponRedemptionCode() + creditsOverageRate() + defaultInvoiceMemo() + externalPlanId() + filter() + initialPhaseOrder() + invoicingThreshold() + netTerms() + perCreditOverageAmount() + planId() + planVersionNumber() + priceOverrides() + removeAdjustments().map { it.forEach { it.validate() } } + removePrices().map { it.forEach { it.validate() } } + replaceAdjustments().map { it.forEach { it.validate() } } + replacePrices().map { it.forEach { it.validate() } } + trialDurationDays() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -404,31 +956,33 @@ constructor( class Builder { - private var changeOption: ChangeOption? = null - private var addAdjustments: MutableList? = null - private var addPrices: MutableList? = null - private var alignBillingWithPlanChangeDate: Boolean? = null - private var autoCollection: Boolean? = null - private var billingCycleAlignment: BillingCycleAlignment? = null - private var billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? = null - private var changeDate: OffsetDateTime? = null - private var couponRedemptionCode: String? = null - private var creditsOverageRate: Double? = null - private var defaultInvoiceMemo: String? = null - private var externalPlanId: String? = null - private var filter: String? = null - private var initialPhaseOrder: Long? = null - private var invoicingThreshold: String? = null - private var netTerms: Long? = null - private var perCreditOverageAmount: Double? = null - private var planId: String? = null - private var planVersionNumber: Long? = null - private var priceOverrides: MutableList? = null - private var removeAdjustments: MutableList? = null - private var removePrices: MutableList? = null - private var replaceAdjustments: MutableList? = null - private var replacePrices: MutableList? = null - private var trialDurationDays: Long? = null + private var changeOption: JsonField? = null + private var addAdjustments: JsonField>? = null + private var addPrices: JsonField>? = null + private var alignBillingWithPlanChangeDate: JsonField = JsonMissing.of() + private var autoCollection: JsonField = JsonMissing.of() + private var billingCycleAlignment: JsonField = JsonMissing.of() + private var billingCycleAnchorConfiguration: + JsonField = + JsonMissing.of() + private var changeDate: JsonField = JsonMissing.of() + private var couponRedemptionCode: JsonField = JsonMissing.of() + private var creditsOverageRate: JsonField = JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var externalPlanId: JsonField = JsonMissing.of() + private var filter: JsonField = JsonMissing.of() + private var initialPhaseOrder: JsonField = JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() + private var perCreditOverageAmount: JsonField = JsonMissing.of() + private var planId: JsonField = JsonMissing.of() + private var planVersionNumber: JsonField = JsonMissing.of() + private var priceOverrides: JsonField>? = null + private var removeAdjustments: JsonField>? = null + private var removePrices: JsonField>? = null + private var replaceAdjustments: JsonField>? = null + private var replacePrices: JsonField>? = null + private var trialDurationDays: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -436,8 +990,9 @@ constructor( subscriptionSchedulePlanChangeBody: SubscriptionSchedulePlanChangeBody ) = apply { changeOption = subscriptionSchedulePlanChangeBody.changeOption - addAdjustments = subscriptionSchedulePlanChangeBody.addAdjustments?.toMutableList() - addPrices = subscriptionSchedulePlanChangeBody.addPrices?.toMutableList() + addAdjustments = + subscriptionSchedulePlanChangeBody.addAdjustments.map { it.toMutableList() } + addPrices = subscriptionSchedulePlanChangeBody.addPrices.map { it.toMutableList() } alignBillingWithPlanChangeDate = subscriptionSchedulePlanChangeBody.alignBillingWithPlanChangeDate autoCollection = subscriptionSchedulePlanChangeBody.autoCollection @@ -456,19 +1011,24 @@ constructor( perCreditOverageAmount = subscriptionSchedulePlanChangeBody.perCreditOverageAmount planId = subscriptionSchedulePlanChangeBody.planId planVersionNumber = subscriptionSchedulePlanChangeBody.planVersionNumber - priceOverrides = subscriptionSchedulePlanChangeBody.priceOverrides?.toMutableList() + priceOverrides = + subscriptionSchedulePlanChangeBody.priceOverrides.map { it.toMutableList() } removeAdjustments = - subscriptionSchedulePlanChangeBody.removeAdjustments?.toMutableList() - removePrices = subscriptionSchedulePlanChangeBody.removePrices?.toMutableList() + subscriptionSchedulePlanChangeBody.removeAdjustments.map { it.toMutableList() } + removePrices = + subscriptionSchedulePlanChangeBody.removePrices.map { it.toMutableList() } replaceAdjustments = - subscriptionSchedulePlanChangeBody.replaceAdjustments?.toMutableList() - replacePrices = subscriptionSchedulePlanChangeBody.replacePrices?.toMutableList() + subscriptionSchedulePlanChangeBody.replaceAdjustments.map { it.toMutableList() } + replacePrices = + subscriptionSchedulePlanChangeBody.replacePrices.map { it.toMutableList() } trialDurationDays = subscriptionSchedulePlanChangeBody.trialDurationDays additionalProperties = subscriptionSchedulePlanChangeBody.additionalProperties.toMutableMap() } - fun changeOption(changeOption: ChangeOption) = apply { + fun changeOption(changeOption: ChangeOption) = changeOption(JsonField.of(changeOption)) + + fun changeOption(changeOption: JsonField) = apply { this.changeOption = changeOption } @@ -476,9 +1036,8 @@ constructor( * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun addAdjustments(addAdjustments: List?) = apply { - this.addAdjustments = addAdjustments?.toMutableList() - } + fun addAdjustments(addAdjustments: List?) = + addAdjustments(JsonField.ofNullable(addAdjustments)) /** * Additional adjustments to be added to the subscription. (Only available for accounts @@ -487,21 +1046,36 @@ constructor( fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) + /** + * Additional adjustments to be added to the subscription. (Only available for accounts + * that have migrated off of legacy subscription overrides) + */ + fun addAdjustments(addAdjustments: JsonField>) = apply { + this.addAdjustments = addAdjustments.map { it.toMutableList() } + } + /** * Additional adjustments to be added to the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ fun addAddAdjustment(addAdjustment: AddAdjustment) = apply { - addAdjustments = (addAdjustments ?: mutableListOf()).apply { add(addAdjustment) } + addAdjustments = + (addAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addAdjustment) + } } /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun addPrices(addPrices: List?) = apply { - this.addPrices = addPrices?.toMutableList() - } + fun addPrices(addPrices: List?) = addPrices(JsonField.ofNullable(addPrices)) /** * Additional prices to be added to the subscription. (Only available for accounts that @@ -509,21 +1083,37 @@ constructor( */ fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + /** + * Additional prices to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun addPrices(addPrices: JsonField>) = apply { + this.addPrices = addPrices.map { it.toMutableList() } + } + /** * Additional prices to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ fun addAddPrice(addPrice: AddPrice) = apply { - addPrices = (addPrices ?: mutableListOf()).apply { add(addPrice) } + addPrices = + (addPrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(addPrice) + } } /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned * with the plan change's effective date. */ - fun alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate: Boolean?) = apply { - this.alignBillingWithPlanChangeDate = alignBillingWithPlanChangeDate - } + fun alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate: Boolean?) = + alignBillingWithPlanChangeDate(JsonField.ofNullable(alignBillingWithPlanChangeDate)) /** * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned @@ -542,14 +1132,22 @@ constructor( alignBillingWithPlanChangeDate.orElse(null) as Boolean? ) + /** + * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned + * with the plan change's effective date. + */ + fun alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate: JsonField) = + apply { + this.alignBillingWithPlanChangeDate = alignBillingWithPlanChangeDate + } + /** * Determines whether issued invoices for this subscription will automatically be * charged with the saved payment method on the due date. If not specified, this * defaults to the behavior configured for this customer. */ - fun autoCollection(autoCollection: Boolean?) = apply { - this.autoCollection = autoCollection - } + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) /** * Determines whether issued invoices for this subscription will automatically be @@ -567,14 +1165,22 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Determines whether issued invoices for this subscription will automatically be + * charged with the saved payment method on the due date. If not specified, this + * defaults to the behavior configured for this customer. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * Reset billing periods to be aligned with the plan change's effective date or start of * the month. Defaults to `unchanged` which keeps subscription's existing billing cycle * alignment. */ - fun billingCycleAlignment(billingCycleAlignment: BillingCycleAlignment?) = apply { - this.billingCycleAlignment = billingCycleAlignment - } + fun billingCycleAlignment(billingCycleAlignment: BillingCycleAlignment?) = + billingCycleAlignment(JsonField.ofNullable(billingCycleAlignment)) /** * Reset billing periods to be aligned with the plan change's effective date or start of @@ -584,19 +1190,37 @@ constructor( fun billingCycleAlignment(billingCycleAlignment: Optional) = billingCycleAlignment(billingCycleAlignment.orElse(null)) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of + * the month. Defaults to `unchanged` which keeps subscription's existing billing cycle + * alignment. + */ + fun billingCycleAlignment(billingCycleAlignment: JsonField) = + apply { + this.billingCycleAlignment = billingCycleAlignment + } + fun billingCycleAnchorConfiguration( billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? - ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + ) = + billingCycleAnchorConfiguration( + JsonField.ofNullable(billingCycleAnchorConfiguration) + ) fun billingCycleAnchorConfiguration( billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { this.billingCycleAnchorConfiguration = billingCycleAnchorConfiguration } + /** * The date that the plan change should take effect. This parameter can only be passed * if the `change_option` is `requested_date`. */ - fun changeDate(changeDate: OffsetDateTime?) = apply { this.changeDate = changeDate } + fun changeDate(changeDate: OffsetDateTime?) = + changeDate(JsonField.ofNullable(changeDate)) /** * The date that the plan change should take effect. This parameter can only be passed @@ -605,14 +1229,21 @@ constructor( fun changeDate(changeDate: Optional) = changeDate(changeDate.orElse(null)) + /** + * The date that the plan change should take effect. This parameter can only be passed + * if the `change_option` is `requested_date`. + */ + fun changeDate(changeDate: JsonField) = apply { + this.changeDate = changeDate + } + /** * Redemption code to be used for this subscription. If the coupon cannot be found by * its redemption code, or cannot be redeemed, an error response will be returned and * the subscription creation or plan change will not be scheduled. */ - fun couponRedemptionCode(couponRedemptionCode: String?) = apply { - this.couponRedemptionCode = couponRedemptionCode - } + fun couponRedemptionCode(couponRedemptionCode: String?) = + couponRedemptionCode(JsonField.ofNullable(couponRedemptionCode)) /** * Redemption code to be used for this subscription. If the coupon cannot be found by @@ -622,10 +1253,18 @@ constructor( fun couponRedemptionCode(couponRedemptionCode: Optional) = couponRedemptionCode(couponRedemptionCode.orElse(null)) - fun creditsOverageRate(creditsOverageRate: Double?) = apply { - this.creditsOverageRate = creditsOverageRate + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by + * its redemption code, or cannot be redeemed, an error response will be returned and + * the subscription creation or plan change will not be scheduled. + */ + fun couponRedemptionCode(couponRedemptionCode: JsonField) = apply { + this.couponRedemptionCode = couponRedemptionCode } + fun creditsOverageRate(creditsOverageRate: Double?) = + creditsOverageRate(JsonField.ofNullable(creditsOverageRate)) + fun creditsOverageRate(creditsOverageRate: Double) = creditsOverageRate(creditsOverageRate as Double?) @@ -633,13 +1272,16 @@ constructor( fun creditsOverageRate(creditsOverageRate: Optional) = creditsOverageRate(creditsOverageRate.orElse(null) as Double?) + fun creditsOverageRate(creditsOverageRate: JsonField) = apply { + this.creditsOverageRate = creditsOverageRate + } + /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) /** * Determines the default memo on this subscription's invoices. Note that if this is not @@ -648,13 +1290,20 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + /** * The external_plan_id of the plan that the given subscription should be switched to. * Note that either this property or `plan_id` must be specified. */ - fun externalPlanId(externalPlanId: String?) = apply { - this.externalPlanId = externalPlanId - } + fun externalPlanId(externalPlanId: String?) = + externalPlanId(JsonField.ofNullable(externalPlanId)) /** * The external_plan_id of the plan that the given subscription should be switched to. @@ -663,13 +1312,21 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * The external_plan_id of the plan that the given subscription should be switched to. + * Note that either this property or `plan_id` must be specified. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + this.externalPlanId = externalPlanId + } + /** * An additional filter to apply to usage queries. This filter must be expressed as a * boolean * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If * null, usage queries will not include any additional filter. */ - fun filter(filter: String?) = apply { this.filter = filter } + fun filter(filter: String?) = filter(JsonField.ofNullable(filter)) /** * An additional filter to apply to usage queries. This filter must be expressed as a @@ -679,10 +1336,17 @@ constructor( */ fun filter(filter: Optional) = filter(filter.orElse(null)) + /** + * An additional filter to apply to usage queries. This filter must be expressed as a + * boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If + * null, usage queries will not include any additional filter. + */ + fun filter(filter: JsonField) = apply { this.filter = filter } + /** The phase of the plan to start with */ - fun initialPhaseOrder(initialPhaseOrder: Long?) = apply { - this.initialPhaseOrder = initialPhaseOrder - } + fun initialPhaseOrder(initialPhaseOrder: Long?) = + initialPhaseOrder(JsonField.ofNullable(initialPhaseOrder)) /** The phase of the plan to start with */ fun initialPhaseOrder(initialPhaseOrder: Long) = @@ -693,14 +1357,18 @@ constructor( fun initialPhaseOrder(initialPhaseOrder: Optional) = initialPhaseOrder(initialPhaseOrder.orElse(null) as Long?) + /** The phase of the plan to start with */ + fun initialPhaseOrder(initialPhaseOrder: JsonField) = apply { + this.initialPhaseOrder = initialPhaseOrder + } + /** * When this subscription's accrued usage reaches this threshold, an invoice will be * issued for the subscription. If not specified, invoices will only be issued at the * end of the billing period. */ - fun invoicingThreshold(invoicingThreshold: String?) = apply { - this.invoicingThreshold = invoicingThreshold - } + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) /** * When this subscription's accrued usage reaches this threshold, an invoice will be @@ -710,12 +1378,21 @@ constructor( fun invoicingThreshold(invoicingThreshold: Optional) = invoicingThreshold(invoicingThreshold.orElse(null)) + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be + * issued for the subscription. If not specified, invoices will only be issued at the + * end of the billing period. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + /** * The net terms determines the difference between the invoice date and the issue date * for the invoice. If you intend the invoice to be due on issue, set this to 0. If not * provided, this defaults to the value specified in the plan. */ - fun netTerms(netTerms: Long?) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) /** * The net terms determines the difference between the invoice date and the issue date @@ -732,9 +1409,15 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) - fun perCreditOverageAmount(perCreditOverageAmount: Double?) = apply { - this.perCreditOverageAmount = perCreditOverageAmount - } + /** + * The net terms determines the difference between the invoice date and the issue date + * for the invoice. If you intend the invoice to be due on issue, set this to 0. If not + * provided, this defaults to the value specified in the plan. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + + fun perCreditOverageAmount(perCreditOverageAmount: Double?) = + perCreditOverageAmount(JsonField.ofNullable(perCreditOverageAmount)) fun perCreditOverageAmount(perCreditOverageAmount: Double) = perCreditOverageAmount(perCreditOverageAmount as Double?) @@ -743,11 +1426,15 @@ constructor( fun perCreditOverageAmount(perCreditOverageAmount: Optional) = perCreditOverageAmount(perCreditOverageAmount.orElse(null) as Double?) + fun perCreditOverageAmount(perCreditOverageAmount: JsonField) = apply { + this.perCreditOverageAmount = perCreditOverageAmount + } + /** * The plan that the given subscription should be switched to. Note that either this * property or `external_plan_id` must be specified. */ - fun planId(planId: String?) = apply { this.planId = planId } + fun planId(planId: String?) = planId(JsonField.ofNullable(planId)) /** * The plan that the given subscription should be switched to. Note that either this @@ -755,13 +1442,18 @@ constructor( */ fun planId(planId: Optional) = planId(planId.orElse(null)) + /** + * The plan that the given subscription should be switched to. Note that either this + * property or `external_plan_id` must be specified. + */ + fun planId(planId: JsonField) = apply { this.planId = planId } + /** * Specifies which version of the plan to change to. If null, the default version will * be used. */ - fun planVersionNumber(planVersionNumber: Long?) = apply { - this.planVersionNumber = planVersionNumber - } + fun planVersionNumber(planVersionNumber: Long?) = + planVersionNumber(JsonField.ofNullable(planVersionNumber)) /** * Specifies which version of the plan to change to. If null, the default version will @@ -778,27 +1470,47 @@ constructor( fun planVersionNumber(planVersionNumber: Optional) = planVersionNumber(planVersionNumber.orElse(null) as Long?) - /** Optionally provide a list of overrides for prices on the plan */ - fun priceOverrides(priceOverrides: List?) = apply { - this.priceOverrides = priceOverrides?.toMutableList() + /** + * Specifies which version of the plan to change to. If null, the default version will + * be used. + */ + fun planVersionNumber(planVersionNumber: JsonField) = apply { + this.planVersionNumber = planVersionNumber } + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(priceOverrides: List?) = + priceOverrides(JsonField.ofNullable(priceOverrides)) + /** Optionally provide a list of overrides for prices on the plan */ fun priceOverrides(priceOverrides: Optional>) = priceOverrides(priceOverrides.orElse(null)) + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(priceOverrides: JsonField>) = apply { + this.priceOverrides = priceOverrides.map { it.toMutableList() } + } + /** Optionally provide a list of overrides for prices on the plan */ fun addPriceOverride(priceOverride: JsonValue) = apply { - priceOverrides = (priceOverrides ?: mutableListOf()).apply { add(priceOverride) } + priceOverrides = + (priceOverrides ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceOverride) + } } /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ - fun removeAdjustments(removeAdjustments: List?) = apply { - this.removeAdjustments = removeAdjustments?.toMutableList() - } + fun removeAdjustments(removeAdjustments: List?) = + removeAdjustments(JsonField.ofNullable(removeAdjustments)) /** * Plan adjustments to be removed from the subscription. (Only available for accounts @@ -807,22 +1519,37 @@ constructor( fun removeAdjustments(removeAdjustments: Optional>) = removeAdjustments(removeAdjustments.orElse(null)) + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts + * that have migrated off of legacy subscription overrides) + */ + fun removeAdjustments(removeAdjustments: JsonField>) = apply { + this.removeAdjustments = removeAdjustments.map { it.toMutableList() } + } + /** * Plan adjustments to be removed from the subscription. (Only available for accounts * that have migrated off of legacy subscription overrides) */ fun addRemoveAdjustment(removeAdjustment: RemoveAdjustment) = apply { removeAdjustments = - (removeAdjustments ?: mutableListOf()).apply { add(removeAdjustment) } + (removeAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removeAdjustment) + } } /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ - fun removePrices(removePrices: List?) = apply { - this.removePrices = removePrices?.toMutableList() - } + fun removePrices(removePrices: List?) = + removePrices(JsonField.ofNullable(removePrices)) /** * Plan prices to be removed from the subscription. (Only available for accounts that @@ -831,21 +1558,37 @@ constructor( fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) + /** + * Plan prices to be removed from the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun removePrices(removePrices: JsonField>) = apply { + this.removePrices = removePrices.map { it.toMutableList() } + } + /** * Plan prices to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) */ fun addRemovePrice(removePrice: RemovePrice) = apply { - removePrices = (removePrices ?: mutableListOf()).apply { add(removePrice) } + removePrices = + (removePrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(removePrice) + } } /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ - fun replaceAdjustments(replaceAdjustments: List?) = apply { - this.replaceAdjustments = replaceAdjustments?.toMutableList() - } + fun replaceAdjustments(replaceAdjustments: List?) = + replaceAdjustments(JsonField.ofNullable(replaceAdjustments)) /** * Plan adjustments to be replaced with additional adjustments on the subscription. @@ -854,22 +1597,37 @@ constructor( fun replaceAdjustments(replaceAdjustments: Optional>) = replaceAdjustments(replaceAdjustments.orElse(null)) + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. + * (Only available for accounts that have migrated off of legacy subscription overrides) + */ + fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { + this.replaceAdjustments = replaceAdjustments.map { it.toMutableList() } + } + /** * Plan adjustments to be replaced with additional adjustments on the subscription. * (Only available for accounts that have migrated off of legacy subscription overrides) */ fun addReplaceAdjustment(replaceAdjustment: ReplaceAdjustment) = apply { replaceAdjustments = - (replaceAdjustments ?: mutableListOf()).apply { add(replaceAdjustment) } + (replaceAdjustments ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(replaceAdjustment) + } } /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ - fun replacePrices(replacePrices: List?) = apply { - this.replacePrices = replacePrices?.toMutableList() - } + fun replacePrices(replacePrices: List?) = + replacePrices(JsonField.ofNullable(replacePrices)) /** * Plan prices to be replaced with additional prices on the subscription. (Only @@ -878,21 +1636,37 @@ constructor( fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) + /** + * Plan prices to be replaced with additional prices on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun replacePrices(replacePrices: JsonField>) = apply { + this.replacePrices = replacePrices.map { it.toMutableList() } + } + /** * Plan prices to be replaced with additional prices on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) */ fun addReplacePrice(replacePrice: ReplacePrice) = apply { - replacePrices = (replacePrices ?: mutableListOf()).apply { add(replacePrice) } + replacePrices = + (replacePrices ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(replacePrice) + } } /** * The duration of the trial period in days. If not provided, this defaults to the value * specified in the plan. If `0` is provided, the trial on the plan will be skipped. */ - fun trialDurationDays(trialDurationDays: Long?) = apply { - this.trialDurationDays = trialDurationDays - } + fun trialDurationDays(trialDurationDays: Long?) = + trialDurationDays(JsonField.ofNullable(trialDurationDays)) /** * The duration of the trial period in days. If not provided, this defaults to the value @@ -909,6 +1683,14 @@ constructor( fun trialDurationDays(trialDurationDays: Optional) = trialDurationDays(trialDurationDays.orElse(null) as Long?) + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun trialDurationDays(trialDurationDays: JsonField) = apply { + this.trialDurationDays = trialDurationDays + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -931,8 +1713,8 @@ constructor( fun build(): SubscriptionSchedulePlanChangeBody = SubscriptionSchedulePlanChangeBody( checkNotNull(changeOption) { "`changeOption` is required but was not set" }, - addAdjustments?.toImmutable(), - addPrices?.toImmutable(), + (addAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (addPrices ?: JsonMissing.of()).map { it.toImmutable() }, alignBillingWithPlanChangeDate, autoCollection, billingCycleAlignment, @@ -949,11 +1731,11 @@ constructor( perCreditOverageAmount, planId, planVersionNumber, - priceOverrides?.toImmutable(), - removeAdjustments?.toImmutable(), - removePrices?.toImmutable(), - replaceAdjustments?.toImmutable(), - replacePrices?.toImmutable(), + (priceOverrides ?: JsonMissing.of()).map { it.toImmutable() }, + (removeAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (removePrices ?: JsonMissing.of()).map { it.toImmutable() }, + (replaceAdjustments ?: JsonMissing.of()).map { it.toImmutable() }, + (replacePrices ?: JsonMissing.of()).map { it.toImmutable() }, trialDurationDays, additionalProperties.toImmutable(), ) @@ -1008,6 +1790,10 @@ constructor( fun changeOption(changeOption: ChangeOption) = apply { body.changeOption(changeOption) } + fun changeOption(changeOption: JsonField) = apply { + body.changeOption(changeOption) + } + /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) @@ -1023,6 +1809,14 @@ constructor( fun addAdjustments(addAdjustments: Optional>) = addAdjustments(addAdjustments.orElse(null)) + /** + * Additional adjustments to be added to the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun addAdjustments(addAdjustments: JsonField>) = apply { + body.addAdjustments(addAdjustments) + } + /** * Additional adjustments to be added to the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) @@ -1043,6 +1837,12 @@ constructor( */ fun addPrices(addPrices: Optional>) = addPrices(addPrices.orElse(null)) + /** + * Additional prices to be added to the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun addPrices(addPrices: JsonField>) = apply { body.addPrices(addPrices) } + /** * Additional prices to be added to the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) @@ -1072,6 +1872,15 @@ constructor( fun alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate: Optional) = alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate.orElse(null) as Boolean?) + /** + * [DEPRECATED] Use billing_cycle_alignment instead. Reset billing periods to be aligned + * with the plan change's effective date. + */ + fun alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate: JsonField) = + apply { + body.alignBillingWithPlanChangeDate(alignBillingWithPlanChangeDate) + } + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. If not specified, this defaults to the @@ -1095,6 +1904,15 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. If not specified, this defaults to the + * behavior configured for this customer. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * Reset billing periods to be aligned with the plan change's effective date or start of the * month. Defaults to `unchanged` which keeps subscription's existing billing cycle @@ -1112,6 +1930,15 @@ constructor( fun billingCycleAlignment(billingCycleAlignment: Optional) = billingCycleAlignment(billingCycleAlignment.orElse(null)) + /** + * Reset billing periods to be aligned with the plan change's effective date or start of the + * month. Defaults to `unchanged` which keeps subscription's existing billing cycle + * alignment. + */ + fun billingCycleAlignment(billingCycleAlignment: JsonField) = apply { + body.billingCycleAlignment(billingCycleAlignment) + } + fun billingCycleAnchorConfiguration( billingCycleAnchorConfiguration: BillingCycleAnchorConfiguration? ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } @@ -1120,6 +1947,10 @@ constructor( billingCycleAnchorConfiguration: Optional ) = billingCycleAnchorConfiguration(billingCycleAnchorConfiguration.orElse(null)) + fun billingCycleAnchorConfiguration( + billingCycleAnchorConfiguration: JsonField + ) = apply { body.billingCycleAnchorConfiguration(billingCycleAnchorConfiguration) } + /** * The date that the plan change should take effect. This parameter can only be passed if * the `change_option` is `requested_date`. @@ -1132,6 +1963,14 @@ constructor( */ fun changeDate(changeDate: Optional) = changeDate(changeDate.orElse(null)) + /** + * The date that the plan change should take effect. This parameter can only be passed if + * the `change_option` is `requested_date`. + */ + fun changeDate(changeDate: JsonField) = apply { + body.changeDate(changeDate) + } + /** * Redemption code to be used for this subscription. If the coupon cannot be found by its * redemption code, or cannot be redeemed, an error response will be returned and the @@ -1149,6 +1988,15 @@ constructor( fun couponRedemptionCode(couponRedemptionCode: Optional) = couponRedemptionCode(couponRedemptionCode.orElse(null)) + /** + * Redemption code to be used for this subscription. If the coupon cannot be found by its + * redemption code, or cannot be redeemed, an error response will be returned and the + * subscription creation or plan change will not be scheduled. + */ + fun couponRedemptionCode(couponRedemptionCode: JsonField) = apply { + body.couponRedemptionCode(couponRedemptionCode) + } + fun creditsOverageRate(creditsOverageRate: Double?) = apply { body.creditsOverageRate(creditsOverageRate) } @@ -1160,6 +2008,10 @@ constructor( fun creditsOverageRate(creditsOverageRate: Optional) = creditsOverageRate(creditsOverageRate.orElse(null) as Double?) + fun creditsOverageRate(creditsOverageRate: JsonField) = apply { + body.creditsOverageRate(creditsOverageRate) + } + /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. @@ -1175,6 +2027,14 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + body.defaultInvoiceMemo(defaultInvoiceMemo) + } + /** * The external_plan_id of the plan that the given subscription should be switched to. Note * that either this property or `plan_id` must be specified. @@ -1188,6 +2048,14 @@ constructor( fun externalPlanId(externalPlanId: Optional) = externalPlanId(externalPlanId.orElse(null)) + /** + * The external_plan_id of the plan that the given subscription should be switched to. Note + * that either this property or `plan_id` must be specified. + */ + fun externalPlanId(externalPlanId: JsonField) = apply { + body.externalPlanId(externalPlanId) + } + /** * An additional filter to apply to usage queries. This filter must be expressed as a * boolean @@ -1204,6 +2072,14 @@ constructor( */ fun filter(filter: Optional) = filter(filter.orElse(null)) + /** + * An additional filter to apply to usage queries. This filter must be expressed as a + * boolean + * [computed property](../guides/extensibility/advanced-metrics#computed-properties). If + * null, usage queries will not include any additional filter. + */ + fun filter(filter: JsonField) = apply { body.filter(filter) } + /** The phase of the plan to start with */ fun initialPhaseOrder(initialPhaseOrder: Long?) = apply { body.initialPhaseOrder(initialPhaseOrder) @@ -1218,6 +2094,11 @@ constructor( fun initialPhaseOrder(initialPhaseOrder: Optional) = initialPhaseOrder(initialPhaseOrder.orElse(null) as Long?) + /** The phase of the plan to start with */ + fun initialPhaseOrder(initialPhaseOrder: JsonField) = apply { + body.initialPhaseOrder(initialPhaseOrder) + } + /** * When this subscription's accrued usage reaches this threshold, an invoice will be issued * for the subscription. If not specified, invoices will only be issued at the end of the @@ -1235,6 +2116,15 @@ constructor( fun invoicingThreshold(invoicingThreshold: Optional) = invoicingThreshold(invoicingThreshold.orElse(null)) + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued + * for the subscription. If not specified, invoices will only be issued at the end of the + * billing period. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + body.invoicingThreshold(invoicingThreshold) + } + /** * The net terms determines the difference between the invoice date and the issue date for * the invoice. If you intend the invoice to be due on issue, set this to 0. If not @@ -1257,6 +2147,13 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + /** + * The net terms determines the difference between the invoice date and the issue date for + * the invoice. If you intend the invoice to be due on issue, set this to 0. If not + * provided, this defaults to the value specified in the plan. + */ + fun netTerms(netTerms: JsonField) = apply { body.netTerms(netTerms) } + fun perCreditOverageAmount(perCreditOverageAmount: Double?) = apply { body.perCreditOverageAmount(perCreditOverageAmount) } @@ -1268,6 +2165,10 @@ constructor( fun perCreditOverageAmount(perCreditOverageAmount: Optional) = perCreditOverageAmount(perCreditOverageAmount.orElse(null) as Double?) + fun perCreditOverageAmount(perCreditOverageAmount: JsonField) = apply { + body.perCreditOverageAmount(perCreditOverageAmount) + } + /** * The plan that the given subscription should be switched to. Note that either this * property or `external_plan_id` must be specified. @@ -1280,6 +2181,12 @@ constructor( */ fun planId(planId: Optional) = planId(planId.orElse(null)) + /** + * The plan that the given subscription should be switched to. Note that either this + * property or `external_plan_id` must be specified. + */ + fun planId(planId: JsonField) = apply { body.planId(planId) } + /** * Specifies which version of the plan to change to. If null, the default version will be * used. @@ -1303,6 +2210,14 @@ constructor( fun planVersionNumber(planVersionNumber: Optional) = planVersionNumber(planVersionNumber.orElse(null) as Long?) + /** + * Specifies which version of the plan to change to. If null, the default version will be + * used. + */ + fun planVersionNumber(planVersionNumber: JsonField) = apply { + body.planVersionNumber(planVersionNumber) + } + /** Optionally provide a list of overrides for prices on the plan */ fun priceOverrides(priceOverrides: List?) = apply { body.priceOverrides(priceOverrides) @@ -1312,6 +2227,11 @@ constructor( fun priceOverrides(priceOverrides: Optional>) = priceOverrides(priceOverrides.orElse(null)) + /** Optionally provide a list of overrides for prices on the plan */ + fun priceOverrides(priceOverrides: JsonField>) = apply { + body.priceOverrides(priceOverrides) + } + /** Optionally provide a list of overrides for prices on the plan */ fun addPriceOverride(priceOverride: JsonValue) = apply { body.addPriceOverride(priceOverride) @@ -1332,6 +2252,14 @@ constructor( fun removeAdjustments(removeAdjustments: Optional>) = removeAdjustments(removeAdjustments.orElse(null)) + /** + * Plan adjustments to be removed from the subscription. (Only available for accounts that + * have migrated off of legacy subscription overrides) + */ + fun removeAdjustments(removeAdjustments: JsonField>) = apply { + body.removeAdjustments(removeAdjustments) + } + /** * Plan adjustments to be removed from the subscription. (Only available for accounts that * have migrated off of legacy subscription overrides) @@ -1355,6 +2283,14 @@ constructor( fun removePrices(removePrices: Optional>) = removePrices(removePrices.orElse(null)) + /** + * Plan prices to be removed from the subscription. (Only available for accounts that have + * migrated off of legacy subscription overrides) + */ + fun removePrices(removePrices: JsonField>) = apply { + body.removePrices(removePrices) + } + /** * Plan prices to be removed from the subscription. (Only available for accounts that have * migrated off of legacy subscription overrides) @@ -1376,6 +2312,14 @@ constructor( fun replaceAdjustments(replaceAdjustments: Optional>) = replaceAdjustments(replaceAdjustments.orElse(null)) + /** + * Plan adjustments to be replaced with additional adjustments on the subscription. (Only + * available for accounts that have migrated off of legacy subscription overrides) + */ + fun replaceAdjustments(replaceAdjustments: JsonField>) = apply { + body.replaceAdjustments(replaceAdjustments) + } + /** * Plan adjustments to be replaced with additional adjustments on the subscription. (Only * available for accounts that have migrated off of legacy subscription overrides) @@ -1399,6 +2343,14 @@ constructor( fun replacePrices(replacePrices: Optional>) = replacePrices(replacePrices.orElse(null)) + /** + * Plan prices to be replaced with additional prices on the subscription. (Only available + * for accounts that have migrated off of legacy subscription overrides) + */ + fun replacePrices(replacePrices: JsonField>) = apply { + body.replacePrices(replacePrices) + } + /** * Plan prices to be replaced with additional prices on the subscription. (Only available * for accounts that have migrated off of legacy subscription overrides) @@ -1430,6 +2382,33 @@ constructor( fun trialDurationDays(trialDurationDays: Optional) = trialDurationDays(trialDurationDays.orElse(null) as Long?) + /** + * The duration of the trial period in days. If not provided, this defaults to the value + * specified in the plan. If `0` is provided, the trial on the plan will be skipped. + */ + fun trialDurationDays(trialDurationDays: JsonField) = apply { + body.trialDurationDays(trialDurationDays) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -1528,25 +2507,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionSchedulePlanChangeParams = SubscriptionSchedulePlanChangeParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, @@ -1623,16 +2583,49 @@ constructor( class AddAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment") private val adjustment: Adjustment, - @JsonProperty("end_date") private val endDate: OffsetDateTime?, - @JsonProperty("plan_phase_order") private val planPhaseOrder: Long?, - @JsonProperty("start_date") private val startDate: OffsetDateTime?, + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") fun adjustment(): Adjustment = adjustment + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** + * The end date of the adjustment interval. This is the date that the adjustment will stop + * affecting prices on the subscription. If null, the adjustment will start when the phase + * or subscription starts. + */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The phase to add this adjustment to. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when the + * phase or subscription starts. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** * The end date of the adjustment interval. This is the date that the adjustment will stop @@ -1640,11 +2633,13 @@ constructor( * or subscription starts. */ @JsonProperty("end_date") - fun endDate(): Optional = Optional.ofNullable(endDate) + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The phase to add this adjustment to. */ @JsonProperty("plan_phase_order") - fun planPhaseOrder(): Optional = Optional.ofNullable(planPhaseOrder) + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** * The start date of the adjustment interval. This is the date that the adjustment will @@ -1652,12 +2647,25 @@ constructor( * phase or subscription starts. */ @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddAdjustment = apply { + if (!validated) { + adjustment() + endDate() + planPhaseOrder() + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -1667,10 +2675,10 @@ constructor( class Builder { - private var adjustment: Adjustment? = null - private var endDate: OffsetDateTime? = null - private var planPhaseOrder: Long? = null - private var startDate: OffsetDateTime? = null + private var adjustment: JsonField? = null + private var endDate: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1683,34 +2691,34 @@ constructor( } /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = apply { this.adjustment = adjustment } + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = apply { - this.adjustment = Adjustment.ofNewPercentageDiscount(newPercentageDiscount) + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment } - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = apply { - this.adjustment = Adjustment.ofNewUsageDiscount(newUsageDiscount) - } + fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = + adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = apply { - this.adjustment = Adjustment.ofNewAmountDiscount(newAmountDiscount) - } + fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = + adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - fun adjustment(newMinimum: Adjustment.NewMinimum) = apply { - this.adjustment = Adjustment.ofNewMinimum(newMinimum) - } + fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = + adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - fun adjustment(newMaximum: Adjustment.NewMaximum) = apply { - this.adjustment = Adjustment.ofNewMaximum(newMaximum) - } + fun adjustment(newMinimum: Adjustment.NewMinimum) = + adjustment(Adjustment.ofNewMinimum(newMinimum)) + + fun adjustment(newMaximum: Adjustment.NewMaximum) = + adjustment(Adjustment.ofNewMaximum(newMaximum)) /** * The end date of the adjustment interval. This is the date that the adjustment will * stop affecting prices on the subscription. If null, the adjustment will start when * the phase or subscription starts. */ - fun endDate(endDate: OffsetDateTime?) = apply { this.endDate = endDate } + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) /** * The end date of the adjustment interval. This is the date that the adjustment will @@ -1719,10 +2727,16 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + /** + * The end date of the adjustment interval. This is the date that the adjustment will + * stop affecting prices on the subscription. If null, the adjustment will start when + * the phase or subscription starts. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** The phase to add this adjustment to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = apply { - this.planPhaseOrder = planPhaseOrder - } + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) /** The phase to add this adjustment to. */ fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) @@ -1732,12 +2746,17 @@ constructor( fun planPhaseOrder(planPhaseOrder: Optional) = planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + /** The phase to add this adjustment to. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + /** * The start date of the adjustment interval. This is the date that the adjustment will * start affecting prices on the subscription. If null, the adjustment will start when * the phase or subscription starts. */ - fun startDate(startDate: OffsetDateTime?) = apply { this.startDate = startDate } + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) /** * The start date of the adjustment interval. This is the date that the adjustment will @@ -1746,6 +2765,15 @@ constructor( */ fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + /** + * The start date of the adjustment interval. This is the date that the adjustment will + * start affecting prices on the subscription. If null, the adjustment will start when + * the phase or subscription starts. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -1788,6 +2816,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newPercentageDiscount(): Optional = Optional.ofNullable(newPercentageDiscount) @@ -1838,6 +2868,26 @@ constructor( } } + fun validate(): Adjustment = apply { + if (!validated) { + if ( + newPercentageDiscount == null && + newUsageDiscount == null && + newAmountDiscount == null && + newMinimum == null && + newMaximum == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + newPercentageDiscount?.validate() + newUsageDiscount?.validate() + newAmountDiscount?.validate() + newMinimum?.validate() + newMaximum?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -1907,29 +2957,40 @@ constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newPercentageDiscount = it, _json = json) + } } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newUsageDiscount = it, _json = json) + } } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newAmountDiscount = it, _json = json) + } } "minimum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMinimum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMinimum = it, _json = json) + } } "maximum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMaximum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMaximum = it, _json = json) + } } } @@ -1963,35 +3024,75 @@ constructor( class NewPercentageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPercentageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + percentageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2001,47 +3102,58 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var percentageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var percentageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = newPercentageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } percentageDiscount = newPercentageDiscount.percentageDiscount isInvoiceLevel = newPercentageDiscount.isInvoiceLevel additionalProperties = newPercentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun percentageDiscount(percentageDiscount: Double) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount } /** @@ -2049,15 +3161,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2089,7 +3201,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(percentageDiscount) { "`percentageDiscount` is required but was not set" }, @@ -2172,34 +3284,74 @@ constructor( class NewUsageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("usage_discount") private val usageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("usage_discount") fun usageDiscount(): Double = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewUsageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + usageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2209,46 +3361,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var usageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var usageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newUsageDiscount: NewUsageDiscount) = apply { adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = newUsageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } usageDiscount = newUsageDiscount.usageDiscount isInvoiceLevel = newUsageDiscount.isInvoiceLevel additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun usageDiscount(usageDiscount: Double) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount } /** @@ -2256,15 +3419,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2296,7 +3459,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(usageDiscount) { "`usageDiscount` is required but was not set" }, @@ -2379,34 +3542,74 @@ constructor( class NewAmountDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("amount_discount") private val amountDiscount: String, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType - @JsonProperty("amount_discount") fun amountDiscount(): String = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAmountDiscount = apply { + if (!validated) { + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2416,46 +3619,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var amountDiscount: String? = null - private var appliesToPriceIds: MutableList? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newAmountDiscount: NewAmountDiscount) = apply { adjustmentType = newAmountDiscount.adjustmentType amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = newAmountDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = newAmountDiscount.isInvoiceLevel additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } - fun amountDiscount(amountDiscount: String) = apply { + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2463,15 +3677,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2506,7 +3720,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, isInvoiceLevel, additionalProperties.toImmutable(), ) @@ -2586,38 +3800,84 @@ constructor( class NewMinimum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMinimum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + itemId() + minimumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2627,51 +3887,64 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var itemId: String? = null - private var minimumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMinimum: NewMinimum) = apply { adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } itemId = newMinimum.itemId minimumAmount = newMinimum.minimumAmount isInvoiceLevel = newMinimum.isInvoiceLevel additionalProperties = newMinimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun minimumAmount(minimumAmount: String) = apply { - this.minimumAmount = minimumAmount - } + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** @@ -2679,15 +3952,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2719,7 +3992,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" @@ -2803,34 +4076,74 @@ constructor( class NewMaximum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("maximum_amount") private val maximumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("maximum_amount") fun maximumAmount(): String = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMaximum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + maximumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -2840,46 +4153,56 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var maximumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMaximum: NewMaximum) = apply { adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = newMaximum.maximumAmount isInvoiceLevel = newMaximum.isInvoiceLevel additionalProperties = newMaximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun maximumAmount(maximumAmount: String) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** @@ -2887,15 +4210,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -2927,7 +4250,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, @@ -3029,71 +4352,161 @@ constructor( class AddPrice @JsonCreator private constructor( - @JsonProperty("discounts") private val discounts: List?, - @JsonProperty("end_date") private val endDate: OffsetDateTime?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("minimum_amount") private val minimumAmount: String?, - @JsonProperty("plan_phase_order") private val planPhaseOrder: Long?, - @JsonProperty("price") private val price: Price?, - @JsonProperty("price_id") private val priceId: String?, - @JsonProperty("start_date") private val startDate: OffsetDateTime?, + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("end_date") + @ExcludeMissing + private val endDate: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("plan_phase_order") + @ExcludeMissing + private val planPhaseOrder: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("start_date") + @ExcludeMissing + private val startDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. + */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** + * The end date of the price interval. This is the date that the price will stop billing on + * the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(): Optional = + Optional.ofNullable(endDate.getNullable("end_date")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The phase to add this price to. */ + fun planPhaseOrder(): Optional = + Optional.ofNullable(planPhaseOrder.getNullable("plan_phase_order")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** + * The start date of the price interval. This is the date that the price will start billing + * on the subscription. If null, billing will start when the phase or subscription starts. + */ + fun startDate(): Optional = + Optional.ofNullable(startDate.getNullable("start_date")) + /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this price. */ @JsonProperty("discounts") - fun discounts(): Optional> = Optional.ofNullable(discounts) + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** * The end date of the price interval. This is the date that the price will stop billing on * the subscription. If null, billing will end when the phase or subscription ends. */ @JsonProperty("end_date") - fun endDate(): Optional = Optional.ofNullable(endDate) + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The external price id of the price to add to the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this * price. */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. */ @JsonProperty("minimum_amount") - fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount) + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The phase to add this price to. */ @JsonProperty("plan_phase_order") - fun planPhaseOrder(): Optional = Optional.ofNullable(planPhaseOrder) + @ExcludeMissing + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") fun price(): Optional = Optional.ofNullable(price) + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId /** * The start date of the price interval. This is the date that the price will start billing * on the subscription. If null, billing will start when the phase or subscription starts. */ @JsonProperty("start_date") - fun startDate(): Optional = Optional.ofNullable(startDate) + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): AddPrice = apply { + if (!validated) { + discounts().map { it.forEach { it.validate() } } + endDate() + externalPriceId() + maximumAmount() + minimumAmount() + planPhaseOrder() + price() + priceId() + startDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3103,20 +4516,20 @@ constructor( class Builder { - private var discounts: MutableList? = null - private var endDate: OffsetDateTime? = null - private var externalPriceId: String? = null - private var maximumAmount: String? = null - private var minimumAmount: String? = null - private var planPhaseOrder: Long? = null - private var price: Price? = null - private var priceId: String? = null - private var startDate: OffsetDateTime? = null + private var discounts: JsonField>? = null + private var endDate: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var planPhaseOrder: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() + private var startDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(addPrice: AddPrice) = apply { - discounts = addPrice.discounts?.toMutableList() + discounts = addPrice.discounts.map { it.toMutableList() } endDate = addPrice.endDate externalPriceId = addPrice.externalPriceId maximumAmount = addPrice.maximumAmount @@ -3132,9 +4545,7 @@ constructor( * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this * price. */ - fun discounts(discounts: List?) = apply { - this.discounts = discounts?.toMutableList() - } + fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this @@ -3142,19 +4553,36 @@ constructor( */ fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this + * price. + */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for this * price. */ fun addDiscount(discount: Discount) = apply { - discounts = (discounts ?: mutableListOf()).apply { add(discount) } + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** * The end date of the price interval. This is the date that the price will stop billing * on the subscription. If null, billing will end when the phase or subscription ends. */ - fun endDate(endDate: OffsetDateTime?) = apply { this.endDate = endDate } + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) /** * The end date of the price interval. This is the date that the price will stop billing @@ -3162,20 +4590,31 @@ constructor( */ fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) + /** + * The end date of the price interval. This is the date that the price will stop billing + * on the subscription. If null, billing will end when the phase or subscription ends. + */ + fun endDate(endDate: JsonField) = apply { this.endDate = endDate } + /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to add to the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this * price. */ - fun maximumAmount(maximumAmount: String?) = apply { this.maximumAmount = maximumAmount } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this @@ -3184,11 +4623,20 @@ constructor( fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for this + * price. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this * price. */ - fun minimumAmount(minimumAmount: String?) = apply { this.minimumAmount = minimumAmount } + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this @@ -3197,11 +4645,18 @@ constructor( fun minimumAmount(minimumAmount: Optional) = minimumAmount(minimumAmount.orElse(null)) - /** The phase to add this price to. */ - fun planPhaseOrder(planPhaseOrder: Long?) = apply { - this.planPhaseOrder = planPhaseOrder + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for this + * price. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The phase to add this price to. */ fun planPhaseOrder(planPhaseOrder: Long) = planPhaseOrder(planPhaseOrder as Long?) @@ -3210,144 +4665,144 @@ constructor( fun planPhaseOrder(planPhaseOrder: Optional) = planPhaseOrder(planPhaseOrder.orElse(null) as Long?) + /** The phase to add this price to. */ + fun planPhaseOrder(planPhaseOrder: JsonField) = apply { + this.planPhaseOrder = planPhaseOrder + } + /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = apply { this.price = price } + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** The definition of a new price to create and add to the subscription. */ fun price(price: Optional) = price(price.orElse(null)) - fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = apply { - this.price = Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice) - } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } - fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = apply { - this.price = Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice) - } + fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = + price(Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice)) - fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = apply { - this.price = Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice) - } + fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = + price(Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice)) - fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = apply { - this.price = Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice) - } + fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = + price(Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice)) - fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = apply { - this.price = Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice) - } + fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = + price(Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice)) - fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice) - } + fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = + price(Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice)) - fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice) - } + fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = + price(Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice)) - fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = apply { - this.price = Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice) - } + fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = + price(Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice)) + + fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = + price(Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice)) fun price( newSubscriptionThresholdTotalAmountPrice: Price.NewSubscriptionThresholdTotalAmountPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionThresholdTotalAmountPrice( newSubscriptionThresholdTotalAmountPrice ) - } + ) fun price(newSubscriptionTieredPackagePrice: Price.NewSubscriptionTieredPackagePrice) = - apply { - this.price = - Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice) - } + price(Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice)) fun price( newSubscriptionTieredWithMinimumPrice: Price.NewSubscriptionTieredWithMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTieredWithMinimumPrice( newSubscriptionTieredWithMinimumPrice ) - } + ) fun price( newSubscriptionUnitWithPercentPrice: Price.NewSubscriptionUnitWithPercentPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithPercentPrice(newSubscriptionUnitWithPercentPrice) - } + ) fun price( newSubscriptionPackageWithAllocationPrice: Price.NewSubscriptionPackageWithAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionPackageWithAllocationPrice( newSubscriptionPackageWithAllocationPrice ) - } + ) fun price( newSubscriptionTierWithProrationPrice: Price.NewSubscriptionTierWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTierWithProrationPrice( newSubscriptionTierWithProrationPrice ) - } + ) fun price( newSubscriptionUnitWithProrationPrice: Price.NewSubscriptionUnitWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithProrationPrice( newSubscriptionUnitWithProrationPrice ) - } + ) fun price( newSubscriptionGroupedAllocationPrice: Price.NewSubscriptionGroupedAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedAllocationPrice( newSubscriptionGroupedAllocationPrice ) - } + ) fun price( newSubscriptionGroupedWithProratedMinimumPrice: Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedWithProratedMinimumPrice( newSubscriptionGroupedWithProratedMinimumPrice ) - } + ) fun price( newSubscriptionBulkWithProrationPrice: Price.NewSubscriptionBulkWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionBulkWithProrationPrice( newSubscriptionBulkWithProrationPrice ) - } + ) /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to add to the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to add to the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + /** * The start date of the price interval. This is the date that the price will start * billing on the subscription. If null, billing will start when the phase or * subscription starts. */ - fun startDate(startDate: OffsetDateTime?) = apply { this.startDate = startDate } + fun startDate(startDate: OffsetDateTime?) = startDate(JsonField.ofNullable(startDate)) /** * The start date of the price interval. This is the date that the price will start @@ -3356,6 +4811,15 @@ constructor( */ fun startDate(startDate: Optional) = startDate(startDate.orElse(null)) + /** + * The start date of the price interval. This is the date that the price will start + * billing on the subscription. If null, billing will start when the phase or + * subscription starts. + */ + fun startDate(startDate: JsonField) = apply { + this.startDate = startDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3377,7 +4841,7 @@ constructor( fun build(): AddPrice = AddPrice( - discounts?.toImmutable(), + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, endDate, externalPriceId, maximumAmount, @@ -3394,37 +4858,81 @@ constructor( class Discount @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("amount_discount") private val amountDiscount: String?, - @JsonProperty("percentage_discount") private val percentageDiscount: Double?, - @JsonProperty("usage_discount") private val usageDiscount: Double?, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount.getNullable("amount_discount")) + + /** + * Only available if discount_type is `percentage`. This is a number between 0 and 1. + */ + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + fun usageDiscount(): Optional = + Optional.ofNullable(usageDiscount.getNullable("usage_discount")) + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** Only available if discount_type is `amount`. */ @JsonProperty("amount_discount") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** * Only available if discount_type is `percentage`. This is a number between 0 and 1. */ @JsonProperty("percentage_discount") - fun percentageDiscount(): Optional = Optional.ofNullable(percentageDiscount) + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ @JsonProperty("usage_discount") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Discount = apply { + if (!validated) { + discountType() + amountDiscount() + percentageDiscount() + usageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -3434,10 +4942,10 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var amountDiscount: String? = null - private var percentageDiscount: Double? = null - private var usageDiscount: Double? = null + private var discountType: JsonField? = null + private var amountDiscount: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -3449,26 +4957,32 @@ constructor( additionalProperties = discount.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = apply { - this.amountDiscount = amountDiscount - } + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) /** Only available if discount_type is `amount`. */ fun amountDiscount(amountDiscount: Optional) = amountDiscount(amountDiscount.orElse(null)) + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + /** * Only available if discount_type is `percentage`. This is a number between 0 * and 1. */ - fun percentageDiscount(percentageDiscount: Double?) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double?) = + percentageDiscount(JsonField.ofNullable(percentageDiscount)) /** * Only available if discount_type is `percentage`. This is a number between 0 @@ -3485,13 +4999,20 @@ constructor( fun percentageDiscount(percentageDiscount: Optional) = percentageDiscount(percentageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + /** * Only available if discount_type is `usage`. Number of usage units that this * discount is for */ - fun usageDiscount(usageDiscount: Double?) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double?) = + usageDiscount(JsonField.ofNullable(usageDiscount)) /** * Only available if discount_type is `usage`. Number of usage units that this @@ -3507,6 +5028,14 @@ constructor( fun usageDiscount(usageDiscount: Optional) = usageDiscount(usageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -3664,6 +5193,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newSubscriptionUnitPrice(): Optional = Optional.ofNullable(newSubscriptionUnitPrice) @@ -3912,6 +5443,52 @@ constructor( } } + fun validate(): Price = apply { + if (!validated) { + if ( + newSubscriptionUnitPrice == null && + newSubscriptionPackagePrice == null && + newSubscriptionMatrixPrice == null && + newSubscriptionTieredPrice == null && + newSubscriptionTieredBpsPrice == null && + newSubscriptionBpsPrice == null && + newSubscriptionBulkBpsPrice == null && + newSubscriptionBulkPrice == null && + newSubscriptionThresholdTotalAmountPrice == null && + newSubscriptionTieredPackagePrice == null && + newSubscriptionTieredWithMinimumPrice == null && + newSubscriptionUnitWithPercentPrice == null && + newSubscriptionPackageWithAllocationPrice == null && + newSubscriptionTierWithProrationPrice == null && + newSubscriptionUnitWithProrationPrice == null && + newSubscriptionGroupedAllocationPrice == null && + newSubscriptionGroupedWithProratedMinimumPrice == null && + newSubscriptionBulkWithProrationPrice == null + ) { + throw OrbInvalidDataException("Unknown Price: $_json") + } + newSubscriptionUnitPrice?.validate() + newSubscriptionPackagePrice?.validate() + newSubscriptionMatrixPrice?.validate() + newSubscriptionTieredPrice?.validate() + newSubscriptionTieredBpsPrice?.validate() + newSubscriptionBpsPrice?.validate() + newSubscriptionBulkBpsPrice?.validate() + newSubscriptionBulkPrice?.validate() + newSubscriptionThresholdTotalAmountPrice?.validate() + newSubscriptionTieredPackagePrice?.validate() + newSubscriptionTieredWithMinimumPrice?.validate() + newSubscriptionUnitWithPercentPrice?.validate() + newSubscriptionPackageWithAllocationPrice?.validate() + newSubscriptionTierWithProrationPrice?.validate() + newSubscriptionUnitWithProrationPrice?.validate() + newSubscriptionGroupedAllocationPrice?.validate() + newSubscriptionGroupedWithProratedMinimumPrice?.validate() + newSubscriptionBulkWithProrationPrice?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -4180,55 +5757,76 @@ constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionUnitPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionUnitPrice = it, _json = json) + } } "package" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionPackagePrice = it, _json = json) } } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionMatrixPrice = it, _json = json) } } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredPrice = it, _json = json) } } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredBpsPrice = it, _json = json) } } "bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBpsPrice = it, _json = json) + } } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionBulkBpsPrice = it, _json = json) } } "bulk" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBulkPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBulkPrice = it, _json = json) + } } "threshold_total_amount" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionThresholdTotalAmountPrice = it, @@ -4240,7 +5838,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredPackagePrice = it, @@ -4252,7 +5852,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredWithMinimumPrice = it, @@ -4264,7 +5866,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithPercentPrice = it, @@ -4276,7 +5880,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionPackageWithAllocationPrice = it, @@ -4288,7 +5894,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTierWithProrationPrice = it, @@ -4300,7 +5908,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithProrationPrice = it, @@ -4312,7 +5922,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedAllocationPrice = it, @@ -4324,7 +5936,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedWithProratedMinimumPrice = it, @@ -4336,7 +5950,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionBulkWithProrationPrice = it, @@ -4406,96 +6022,229 @@ constructor( class NewSubscriptionUnitPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -4503,19 +6252,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4525,22 +6300,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4568,25 +6346,41 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -4595,13 +6389,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -4618,13 +6419,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -4634,12 +6443,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -4654,11 +6470,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -4666,22 +6489,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -4698,22 +6530,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -4723,12 +6570,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -4737,11 +6592,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -4750,6 +6613,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -4932,18 +6803,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -4953,7 +6840,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -4964,7 +6851,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -5023,22 +6915,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5048,8 +6964,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -5063,10 +6979,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5187,22 +7110,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5212,8 +7159,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -5228,10 +7175,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -5361,6 +7315,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5442,96 +7404,229 @@ constructor( class NewSubscriptionPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -5539,19 +7634,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -5561,22 +7682,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5605,17 +7729,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } @@ -5623,9 +7763,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -5634,13 +7773,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -5657,13 +7803,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -5673,12 +7827,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -5693,11 +7854,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -5705,22 +7873,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -5737,22 +7914,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -5762,12 +7954,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -5776,11 +7976,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -5789,6 +7997,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -5973,25 +8189,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6001,8 +8244,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6014,7 +8257,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -6022,7 +8269,13 @@ constructor( * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { this.packageSize = packageSize } @@ -6086,22 +8339,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6111,8 +8388,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6126,10 +8403,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6250,22 +8534,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6275,8 +8583,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -6291,10 +8599,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -6424,6 +8739,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6505,96 +8828,229 @@ constructor( class NewSubscriptionMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -6602,19 +9058,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionMatrixPrice = apply { + if (!validated) { + cadence() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -6624,22 +9106,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6668,27 +9153,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -6697,13 +9197,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -6720,13 +9227,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -6736,12 +9251,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -6756,11 +9278,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -6768,22 +9297,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -6800,22 +9338,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -6825,12 +9378,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -6839,11 +9400,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -6852,6 +9421,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -6984,31 +9561,66 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ @JsonProperty("matrix_values") - fun matrixValues(): List = matrixValues + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7018,17 +9630,17 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -7036,29 +9648,61 @@ constructor( * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { matrixValues = - (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -7091,11 +9735,11 @@ constructor( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -7105,28 +9749,55 @@ constructor( @JsonCreator private constructor( @JsonProperty("dimension_values") - private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7136,14 +9807,15 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() @@ -7154,8 +9826,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -7165,13 +9845,23 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { - add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -7202,7 +9892,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -7306,22 +9996,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7331,8 +10045,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -7346,10 +10060,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7470,22 +10191,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7495,8 +10240,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -7511,10 +10256,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -7644,6 +10396,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7725,96 +10485,229 @@ constructor( class NewSubscriptionTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -7822,19 +10715,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -7844,22 +10763,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -7888,17 +10810,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } @@ -7906,9 +10844,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -7917,13 +10854,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -7940,13 +10884,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -7956,12 +10908,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -7976,11 +10935,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -7988,22 +10954,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -8020,22 +10995,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -8045,12 +11035,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -8059,11 +11057,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -8072,6 +11078,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -8256,18 +11270,34 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8277,26 +11307,42 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** * Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for rating based on total usage quantities into the specified tier + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -8324,7 +11370,7 @@ constructor( fun build(): TieredConfig = TieredConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -8333,30 +11379,64 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Exclusive tier ending value. If null, this is treated as the last tier + */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** * Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8366,9 +11446,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -8381,10 +11461,19 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -8392,7 +11481,8 @@ constructor( * Exclusive tier ending value. If null, this is treated as the last * tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = + lastUnit(JsonField.ofNullable(lastUnit)) /** * Exclusive tier ending value. If null, this is treated as the last @@ -8410,6 +11500,14 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** + * Exclusive tier ending value. If null, this is treated as the last + * tier + */ + fun lastUnit(lastUnit: JsonField) = apply { + this.lastUnit = lastUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -8489,22 +11587,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8514,8 +11636,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -8529,10 +11651,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8653,22 +11782,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8678,8 +11831,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -8694,10 +11847,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -8827,6 +11987,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -8908,97 +12076,230 @@ constructor( class NewSubscriptionTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_bps_config") - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -9006,19 +12307,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredBpsPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9028,22 +12355,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -9073,17 +12403,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } @@ -9091,9 +12437,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -9102,13 +12447,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -9125,13 +12477,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -9141,12 +12501,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -9161,11 +12528,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -9173,22 +12547,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -9205,22 +12588,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -9230,12 +12628,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -9244,11 +12650,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -9257,6 +12671,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -9441,7 +12863,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -9450,12 +12874,29 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9465,13 +12906,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -9480,14 +12921,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -9515,7 +12973,7 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -9524,33 +12982,71 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Inclusive tier starting value */ + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9560,10 +13056,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -9577,31 +13073,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -9680,22 +13191,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9705,8 +13240,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -9720,10 +13255,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -9844,22 +13386,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -9869,8 +13435,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -9885,10 +13451,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10018,6 +13591,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10099,96 +13680,229 @@ constructor( class NewSubscriptionBpsPrice @JsonCreator private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -10196,19 +13910,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10218,22 +13958,25 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -10260,26 +14003,42 @@ constructor( newSubscriptionBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -10288,13 +14047,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -10311,13 +14077,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -10327,12 +14101,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -10347,11 +14128,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -10359,22 +14147,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -10391,22 +14188,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -10416,12 +14228,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -10430,11 +14250,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -10443,6 +14271,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -10491,23 +14327,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10517,8 +14375,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -10530,17 +14388,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -10731,22 +14596,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10756,8 +14645,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -10771,10 +14660,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -10895,22 +14791,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -10920,8 +14840,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -10936,10 +14856,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -11069,6 +14996,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11150,96 +15085,229 @@ constructor( class NewSubscriptionBulkBpsPrice @JsonCreator private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -11247,19 +15315,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11269,22 +15363,25 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -11312,28 +15409,43 @@ constructor( newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -11342,13 +15454,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -11365,13 +15484,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -11381,12 +15508,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -11401,11 +15535,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -11413,22 +15554,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -11445,22 +15595,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -11470,12 +15635,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -11484,11 +15657,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -11497,6 +15678,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -11547,7 +15736,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -11556,12 +15747,29 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single + * tier based on total volume + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11571,13 +15779,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -11585,14 +15793,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a + * single tier based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -11620,7 +15845,7 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -11629,29 +15854,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11661,9 +15916,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -11676,26 +15931,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -11905,22 +16171,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -11930,8 +16220,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -11945,10 +16235,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12069,22 +16366,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12094,8 +16415,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -12110,10 +16431,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -12243,6 +16571,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12324,96 +16660,229 @@ constructor( class NewSubscriptionBulkPrice @JsonCreator private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -12421,19 +16890,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12443,22 +16938,25 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -12485,26 +16983,42 @@ constructor( newSubscriptionBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -12513,13 +17027,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -12536,13 +17057,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -12552,12 +17081,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -12572,11 +17108,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -12584,22 +17127,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -12616,22 +17168,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -12641,12 +17208,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -12655,11 +17230,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -12668,6 +17251,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -12716,18 +17307,34 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12737,22 +17344,36 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -12780,7 +17401,7 @@ constructor( fun build(): BulkConfig = BulkConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -12789,24 +17410,48 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -12816,8 +17461,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -12829,14 +17474,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits - } + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = @@ -12849,6 +17497,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -13059,22 +17712,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13084,8 +17761,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -13099,10 +17776,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13223,22 +17907,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13248,8 +17956,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -13264,10 +17972,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -13397,6 +18112,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13478,42 +18201,166 @@ constructor( class NewSubscriptionThresholdTotalAmountPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("threshold_total_amount_config") fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = thresholdTotalAmountConfig /** @@ -13521,56 +18368,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -13578,19 +18434,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -13600,22 +18482,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -13650,27 +18536,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig( thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -13679,13 +18581,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -13702,13 +18611,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -13718,12 +18635,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -13738,11 +18662,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -13750,22 +18681,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -13782,22 +18722,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -13807,12 +18762,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -13821,11 +18784,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -13834,6 +18805,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -14026,6 +19005,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14097,22 +19084,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14122,8 +19133,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14137,10 +19148,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14261,22 +19279,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14286,8 +19328,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -14302,10 +19344,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -14435,6 +19484,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14516,98 +19573,230 @@ constructor( class NewSubscriptionTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") - private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -14615,19 +19804,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -14637,22 +19852,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -14682,27 +19900,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -14711,13 +19945,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -14734,13 +19975,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -14750,12 +19999,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -14770,11 +20026,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -14782,22 +20045,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -14814,22 +20086,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -14839,12 +20126,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -14853,11 +20148,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -14866,6 +20169,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -15058,6 +20369,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15128,22 +20447,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15153,8 +20496,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -15168,10 +20511,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15292,22 +20642,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15317,8 +20691,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -15333,10 +20707,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -15466,6 +20847,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15547,98 +20936,232 @@ constructor( class NewSubscriptionTieredWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -15646,19 +21169,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -15668,22 +21217,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -15717,28 +21269,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -15747,13 +21313,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -15770,13 +21343,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -15786,12 +21367,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -15806,11 +21394,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -15818,22 +21413,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -15850,22 +21454,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -15875,12 +21494,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -15889,11 +21516,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -15902,6 +21537,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -16094,6 +21737,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16165,22 +21816,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16190,8 +21865,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -16205,10 +21880,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16329,22 +22011,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16354,8 +22060,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -16370,10 +22076,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -16503,6 +22216,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16584,98 +22305,232 @@ constructor( class NewSubscriptionUnitWithPercentPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -16683,19 +22538,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -16705,22 +22586,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -16751,28 +22635,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -16781,13 +22679,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -16804,13 +22709,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -16820,12 +22733,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -16840,11 +22760,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -16852,22 +22779,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -16884,22 +22820,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -16909,12 +22860,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -16923,11 +22882,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -16936,6 +22903,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -17128,6 +23103,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17198,22 +23181,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17223,8 +23230,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -17238,10 +23245,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17362,22 +23376,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17387,8 +23425,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -17403,10 +23441,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -17536,6 +23581,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17617,42 +23670,166 @@ constructor( class NewSubscriptionPackageWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_with_allocation_config") fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = packageWithAllocationConfig /** @@ -17660,56 +23837,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -17717,19 +23903,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -17739,22 +23951,27 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -17790,27 +24007,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -17819,13 +24052,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -17842,13 +24082,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -17858,12 +24106,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -17878,11 +24133,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -17890,22 +24152,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -17922,22 +24193,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -17947,12 +24233,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -17961,11 +24255,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -17974,6 +24276,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -18166,6 +24476,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18238,22 +24556,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18263,8 +24605,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -18278,10 +24620,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18402,22 +24751,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18427,8 +24800,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -18443,10 +24816,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -18576,6 +24956,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18657,42 +25045,166 @@ constructor( class NewSubscriptionTierWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_with_proration_config") fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = tieredWithProrationConfig /** @@ -18700,56 +25212,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -18757,19 +25278,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTierWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -18779,22 +25326,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -18828,27 +25379,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig( tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -18857,13 +25424,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -18880,13 +25454,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -18896,12 +25478,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -18916,11 +25505,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -18928,22 +25524,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -18960,22 +25565,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -18985,12 +25605,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -18999,11 +25627,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -19012,6 +25648,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -19204,6 +25848,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19275,22 +25927,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19300,8 +25976,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -19315,10 +25991,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19439,22 +26122,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19464,8 +26171,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -19480,10 +26187,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -19613,6 +26327,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19694,98 +26416,232 @@ constructor( class NewSubscriptionUnitWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -19793,19 +26649,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -19815,22 +26697,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -19864,28 +26749,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -19894,13 +26793,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -19917,13 +26823,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -19933,12 +26847,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -19953,11 +26874,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -19965,22 +26893,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -19997,22 +26934,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -20022,12 +26974,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -20036,11 +26996,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -20049,6 +27017,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -20241,6 +27217,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20312,22 +27296,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20337,8 +27345,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -20352,10 +27360,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20476,22 +27491,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20501,8 +27540,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -20517,10 +27556,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -20650,6 +27696,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20731,98 +27785,232 @@ constructor( class NewSubscriptionGroupedAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -20830,19 +28018,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + if (!validated) { + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -20852,22 +28066,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -20901,28 +28118,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -20931,13 +28162,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -20954,13 +28192,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -20970,12 +28216,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -20990,11 +28243,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -21002,22 +28262,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -21034,22 +28303,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -21059,12 +28343,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -21073,11 +28365,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -21086,6 +28386,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -21226,6 +28534,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21349,22 +28665,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21374,8 +28714,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -21389,10 +28729,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21513,22 +28860,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21538,8 +28909,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -21554,10 +28925,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -21687,6 +29065,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21768,99 +29154,235 @@ constructor( class NewSubscriptionGroupedWithProratedMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") - @JsonProperty("grouped_with_prorated_minimum_config") fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -21868,19 +29390,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -21890,24 +29438,27 @@ constructor( class Builder { - private var cadence: Cadence? = null + private var cadence: JsonField? = null private var groupedWithProratedMinimumConfig: - GroupedWithProratedMinimumConfig? = + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -21948,29 +29499,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -21979,13 +29550,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -22002,13 +29580,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -22018,12 +29604,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -22038,11 +29631,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -22050,22 +29650,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -22082,22 +29691,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -22107,12 +29731,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -22121,11 +29753,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -22134,6 +29774,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -22274,6 +29922,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22399,22 +30055,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22424,8 +30104,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -22439,10 +30119,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22563,22 +30250,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22588,8 +30299,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -22604,10 +30315,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -22737,6 +30455,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22819,97 +30545,231 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -22917,19 +30777,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -22939,22 +30825,25 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -22988,28 +30877,42 @@ constructor( } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -23018,13 +30921,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -23041,13 +30951,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -23057,12 +30975,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -23077,11 +31002,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -23089,22 +31021,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -23121,22 +31062,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -23146,12 +31102,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -23160,11 +31124,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -23173,6 +31145,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -23231,6 +31211,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23436,22 +31424,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23461,8 +31473,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -23476,10 +31488,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23600,22 +31619,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23625,8 +31668,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -23641,10 +31684,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -23774,6 +31824,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23937,9 +31995,11 @@ constructor( class BillingCycleAnchorConfiguration @JsonCreator private constructor( - @JsonProperty("day") private val day: Long, - @JsonProperty("month") private val month: Long?, - @JsonProperty("year") private val year: Long?, + @JsonProperty("day") @ExcludeMissing private val day: JsonField = JsonMissing.of(), + @JsonProperty("month") + @ExcludeMissing + private val month: JsonField = JsonMissing.of(), + @JsonProperty("year") @ExcludeMissing private val year: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -23950,24 +32010,55 @@ constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") fun day(): Long = day + fun day(): Long = day.getRequired("day") /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") fun month(): Optional = Optional.ofNullable(month) + fun month(): Optional = Optional.ofNullable(month.getNullable("month")) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") fun year(): Optional = Optional.ofNullable(year) + fun year(): Optional = Optional.ofNullable(year.getNullable("year")) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on + * 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleAnchorConfiguration = apply { + if (!validated) { + day() + month() + year() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -23977,9 +32068,9 @@ constructor( class Builder { - private var day: Long? = null - private var month: Long? = null - private var year: Long? = null + private var day: JsonField? = null + private var month: JsonField = JsonMissing.of() + private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -23998,13 +32089,21 @@ constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - fun day(day: Long) = apply { this.day = day } + fun day(day: Long) = day(JsonField.of(day)) + + /** + * The day of the month on which the billing cycle is anchored. If the maximum number of + * days in a month is greater than this value, the last day of the month is the billing + * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the + * 30th. + */ + fun day(day: JsonField) = apply { this.day = day } /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long?) = apply { this.month = month } + fun month(month: Long?) = month(JsonField.ofNullable(month)) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -24019,11 +32118,17 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun month(month: Optional) = month(month.orElse(null) as Long?) + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: JsonField) = apply { this.month = month } + /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long?) = apply { this.year = year } + fun year(year: Long?) = year(JsonField.ofNullable(year)) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -24038,6 +32143,12 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun year(year: Optional) = year(year.orElse(null) as Long?) + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: JsonField) = apply { this.year = year } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24088,18 +32199,34 @@ constructor( class RemoveAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment_id") private val adjustmentId: String, + @JsonProperty("adjustment_id") + @ExcludeMissing + private val adjustmentId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the adjustment to remove on the subscription. */ - @JsonProperty("adjustment_id") fun adjustmentId(): String = adjustmentId + fun adjustmentId(): String = adjustmentId.getRequired("adjustment_id") + + /** The id of the adjustment to remove on the subscription. */ + @JsonProperty("adjustment_id") + @ExcludeMissing + fun _adjustmentId(): JsonField = adjustmentId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemoveAdjustment = apply { + if (!validated) { + adjustmentId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24109,7 +32236,7 @@ constructor( class Builder { - private var adjustmentId: String? = null + private var adjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24119,7 +32246,12 @@ constructor( } /** The id of the adjustment to remove on the subscription. */ - fun adjustmentId(adjustmentId: String) = apply { this.adjustmentId = adjustmentId } + fun adjustmentId(adjustmentId: String) = adjustmentId(JsonField.of(adjustmentId)) + + /** The id of the adjustment to remove on the subscription. */ + fun adjustmentId(adjustmentId: JsonField) = apply { + this.adjustmentId = adjustmentId + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24169,23 +32301,45 @@ constructor( class RemovePrice @JsonCreator private constructor( - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("price_id") private val priceId: String?, + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** The id of the price to remove on the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + /** The external price id of the price to remove on the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** The id of the price to remove on the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): RemovePrice = apply { + if (!validated) { + externalPriceId() + priceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24195,8 +32349,8 @@ constructor( class Builder { - private var externalPriceId: String? = null - private var priceId: String? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24207,20 +32361,27 @@ constructor( } /** The external price id of the price to remove on the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to remove on the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** The external price id of the price to remove on the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** The id of the price to remove on the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to remove on the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to remove on the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -24270,23 +32431,47 @@ constructor( class ReplaceAdjustment @JsonCreator private constructor( - @JsonProperty("adjustment") private val adjustment: Adjustment, - @JsonProperty("replaces_adjustment_id") private val replacesAdjustmentId: String, + @JsonProperty("adjustment") + @ExcludeMissing + private val adjustment: JsonField = JsonMissing.of(), + @JsonProperty("replaces_adjustment_id") + @ExcludeMissing + private val replacesAdjustmentId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The definition of a new adjustment to create and add to the subscription. */ - @JsonProperty("adjustment") fun adjustment(): Adjustment = adjustment + fun adjustment(): Adjustment = adjustment.getRequired("adjustment") + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(): String = + replacesAdjustmentId.getRequired("replaces_adjustment_id") + + /** The definition of a new adjustment to create and add to the subscription. */ + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The id of the adjustment on the plan to replace in the subscription. */ @JsonProperty("replaces_adjustment_id") - fun replacesAdjustmentId(): String = replacesAdjustmentId + @ExcludeMissing + fun _replacesAdjustmentId(): JsonField = replacesAdjustmentId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReplaceAdjustment = apply { + if (!validated) { + adjustment() + replacesAdjustmentId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24296,8 +32481,8 @@ constructor( class Builder { - private var adjustment: Adjustment? = null - private var replacesAdjustmentId: String? = null + private var adjustment: JsonField? = null + private var replacesAdjustmentId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -24308,30 +32493,34 @@ constructor( } /** The definition of a new adjustment to create and add to the subscription. */ - fun adjustment(adjustment: Adjustment) = apply { this.adjustment = adjustment } + fun adjustment(adjustment: Adjustment) = adjustment(JsonField.of(adjustment)) - fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = apply { - this.adjustment = Adjustment.ofNewPercentageDiscount(newPercentageDiscount) + /** The definition of a new adjustment to create and add to the subscription. */ + fun adjustment(adjustment: JsonField) = apply { + this.adjustment = adjustment } - fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = apply { - this.adjustment = Adjustment.ofNewUsageDiscount(newUsageDiscount) - } + fun adjustment(newPercentageDiscount: Adjustment.NewPercentageDiscount) = + adjustment(Adjustment.ofNewPercentageDiscount(newPercentageDiscount)) - fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = apply { - this.adjustment = Adjustment.ofNewAmountDiscount(newAmountDiscount) - } + fun adjustment(newUsageDiscount: Adjustment.NewUsageDiscount) = + adjustment(Adjustment.ofNewUsageDiscount(newUsageDiscount)) - fun adjustment(newMinimum: Adjustment.NewMinimum) = apply { - this.adjustment = Adjustment.ofNewMinimum(newMinimum) - } + fun adjustment(newAmountDiscount: Adjustment.NewAmountDiscount) = + adjustment(Adjustment.ofNewAmountDiscount(newAmountDiscount)) - fun adjustment(newMaximum: Adjustment.NewMaximum) = apply { - this.adjustment = Adjustment.ofNewMaximum(newMaximum) - } + fun adjustment(newMinimum: Adjustment.NewMinimum) = + adjustment(Adjustment.ofNewMinimum(newMinimum)) + + fun adjustment(newMaximum: Adjustment.NewMaximum) = + adjustment(Adjustment.ofNewMaximum(newMaximum)) + + /** The id of the adjustment on the plan to replace in the subscription. */ + fun replacesAdjustmentId(replacesAdjustmentId: String) = + replacesAdjustmentId(JsonField.of(replacesAdjustmentId)) /** The id of the adjustment on the plan to replace in the subscription. */ - fun replacesAdjustmentId(replacesAdjustmentId: String) = apply { + fun replacesAdjustmentId(replacesAdjustmentId: JsonField) = apply { this.replacesAdjustmentId = replacesAdjustmentId } @@ -24377,6 +32566,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newPercentageDiscount(): Optional = Optional.ofNullable(newPercentageDiscount) @@ -24427,6 +32618,26 @@ constructor( } } + fun validate(): Adjustment = apply { + if (!validated) { + if ( + newPercentageDiscount == null && + newUsageDiscount == null && + newAmountDiscount == null && + newMinimum == null && + newMaximum == null + ) { + throw OrbInvalidDataException("Unknown Adjustment: $_json") + } + newPercentageDiscount?.validate() + newUsageDiscount?.validate() + newAmountDiscount?.validate() + newMinimum?.validate() + newMaximum?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -24496,29 +32707,40 @@ constructor( when (adjustmentType) { "percentage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newPercentageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newPercentageDiscount = it, _json = json) + } } "usage_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newUsageDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newUsageDiscount = it, _json = json) + } } "amount_discount" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newAmountDiscount = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Adjustment(newAmountDiscount = it, _json = json) + } } "minimum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMinimum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMinimum = it, _json = json) + } } "maximum" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Adjustment(newMaximum = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { it.validate() } + ?.let { + return Adjustment(newMaximum = it, _json = json) + } } } @@ -24552,35 +32774,75 @@ constructor( class NewPercentageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("percentage_discount") private val percentageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun percentageDiscount(): Double = + percentageDiscount.getRequired("percentage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds @JsonProperty("percentage_discount") - fun percentageDiscount(): Double = percentageDiscount + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewPercentageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + percentageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24590,47 +32852,58 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var percentageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var percentageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newPercentageDiscount: NewPercentageDiscount) = apply { adjustmentType = newPercentageDiscount.adjustmentType - appliesToPriceIds = newPercentageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newPercentageDiscount.appliesToPriceIds.map { it.toMutableList() } percentageDiscount = newPercentageDiscount.percentageDiscount isInvoiceLevel = newPercentageDiscount.isInvoiceLevel additionalProperties = newPercentageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun percentageDiscount(percentageDiscount: Double) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double) = + percentageDiscount(JsonField.of(percentageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount } /** @@ -24638,15 +32911,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24678,7 +32951,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(percentageDiscount) { "`percentageDiscount` is required but was not set" }, @@ -24761,34 +33034,74 @@ constructor( class NewUsageDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("usage_discount") private val usageDiscount: Double, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("usage_discount") fun usageDiscount(): Double = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewUsageDiscount = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + usageDiscount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -24798,46 +33111,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var usageDiscount: Double? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var usageDiscount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newUsageDiscount: NewUsageDiscount) = apply { adjustmentType = newUsageDiscount.adjustmentType - appliesToPriceIds = newUsageDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newUsageDiscount.appliesToPriceIds.map { it.toMutableList() } usageDiscount = newUsageDiscount.usageDiscount isInvoiceLevel = newUsageDiscount.isInvoiceLevel additionalProperties = newUsageDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun usageDiscount(usageDiscount: Double) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double) = + usageDiscount(JsonField.of(usageDiscount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount } /** @@ -24845,15 +33169,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -24885,7 +33209,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(usageDiscount) { "`usageDiscount` is required but was not set" }, @@ -24968,34 +33292,74 @@ constructor( class NewAmountDiscount @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("amount_discount") private val amountDiscount: String, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + fun amountDiscount(): String = amountDiscount.getRequired("amount_discount") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType - @JsonProperty("amount_discount") fun amountDiscount(): String = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewAmountDiscount = apply { + if (!validated) { + adjustmentType() + amountDiscount() + appliesToPriceIds() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25005,46 +33369,57 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var amountDiscount: String? = null - private var appliesToPriceIds: MutableList? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newAmountDiscount: NewAmountDiscount) = apply { adjustmentType = newAmountDiscount.adjustmentType amountDiscount = newAmountDiscount.amountDiscount - appliesToPriceIds = newAmountDiscount.appliesToPriceIds.toMutableList() + appliesToPriceIds = + newAmountDiscount.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = newAmountDiscount.isInvoiceLevel additionalProperties = newAmountDiscount.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } - fun amountDiscount(amountDiscount: String) = apply { + fun amountDiscount(amountDiscount: String) = + amountDiscount(JsonField.of(amountDiscount)) + + fun amountDiscount(amountDiscount: JsonField) = apply { this.amountDiscount = amountDiscount } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } - } - - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -25052,15 +33427,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -25095,7 +33470,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, isInvoiceLevel, additionalProperties.toImmutable(), ) @@ -25175,38 +33550,84 @@ constructor( class NewMinimum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMinimum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + itemId() + minimumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25216,51 +33637,64 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var itemId: String? = null - private var minimumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMinimum: NewMinimum) = apply { adjustmentType = newMinimum.adjustmentType - appliesToPriceIds = newMinimum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMinimum.appliesToPriceIds.map { it.toMutableList() } itemId = newMinimum.itemId minimumAmount = newMinimum.minimumAmount isInvoiceLevel = newMinimum.isInvoiceLevel additionalProperties = newMinimum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The item ID that revenue from this minimum will be attributed to. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun minimumAmount(minimumAmount: String) = apply { - this.minimumAmount = minimumAmount - } + /** The item ID that revenue from this minimum will be attributed to. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount } /** @@ -25268,15 +33702,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -25308,7 +33742,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(itemId) { "`itemId` is required but was not set" }, checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" @@ -25392,34 +33826,74 @@ constructor( class NewMaximum @JsonCreator private constructor( - @JsonProperty("adjustment_type") private val adjustmentType: AdjustmentType, - @JsonProperty("applies_to_price_ids") private val appliesToPriceIds: List, - @JsonProperty("maximum_amount") private val maximumAmount: String, - @JsonProperty("is_invoice_level") private val isInvoiceLevel: Boolean?, + @JsonProperty("adjustment_type") + @ExcludeMissing + private val adjustmentType: JsonField = JsonMissing.of(), + @JsonProperty("applies_to_price_ids") + @ExcludeMissing + private val appliesToPriceIds: JsonField> = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("is_invoice_level") + @ExcludeMissing + private val isInvoiceLevel: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun adjustmentType(): AdjustmentType = adjustmentType.getRequired("adjustment_type") + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(): List = + appliesToPriceIds.getRequired("applies_to_price_ids") + + fun maximumAmount(): String = maximumAmount.getRequired("maximum_amount") + + /** + * When false, this adjustment will be applied to a single price. Otherwise, it will + * be applied at the invoice level, possibly to multiple prices. + */ + fun isInvoiceLevel(): Optional = + Optional.ofNullable(isInvoiceLevel.getNullable("is_invoice_level")) + @JsonProperty("adjustment_type") - fun adjustmentType(): AdjustmentType = adjustmentType + @ExcludeMissing + fun _adjustmentType(): JsonField = adjustmentType /** The set of price IDs to which this adjustment applies. */ @JsonProperty("applies_to_price_ids") - fun appliesToPriceIds(): List = appliesToPriceIds + @ExcludeMissing + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("maximum_amount") fun maximumAmount(): String = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * When false, this adjustment will be applied to a single price. Otherwise, it will * be applied at the invoice level, possibly to multiple prices. */ @JsonProperty("is_invoice_level") - fun isInvoiceLevel(): Optional = Optional.ofNullable(isInvoiceLevel) + @ExcludeMissing + fun _isInvoiceLevel(): JsonField = isInvoiceLevel @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewMaximum = apply { + if (!validated) { + adjustmentType() + appliesToPriceIds() + maximumAmount() + isInvoiceLevel() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25429,46 +33903,56 @@ constructor( class Builder { - private var adjustmentType: AdjustmentType? = null - private var appliesToPriceIds: MutableList? = null - private var maximumAmount: String? = null - private var isInvoiceLevel: Boolean? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var maximumAmount: JsonField? = null + private var isInvoiceLevel: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(newMaximum: NewMaximum) = apply { adjustmentType = newMaximum.adjustmentType - appliesToPriceIds = newMaximum.appliesToPriceIds.toMutableList() + appliesToPriceIds = newMaximum.appliesToPriceIds.map { it.toMutableList() } maximumAmount = newMaximum.maximumAmount isInvoiceLevel = newMaximum.isInvoiceLevel additionalProperties = newMaximum.additionalProperties.toMutableMap() } - fun adjustmentType(adjustmentType: AdjustmentType) = apply { + fun adjustmentType(adjustmentType: AdjustmentType) = + adjustmentType(JsonField.of(adjustmentType)) + + fun adjustmentType(adjustmentType: JsonField) = apply { this.adjustmentType = adjustmentType } /** The set of price IDs to which this adjustment applies. */ - fun appliesToPriceIds(appliesToPriceIds: List) = apply { - this.appliesToPriceIds = appliesToPriceIds.toMutableList() + fun appliesToPriceIds(appliesToPriceIds: List) = + appliesToPriceIds(JsonField.of(appliesToPriceIds)) + + /** The set of price IDs to which this adjustment applies. */ + fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } } /** The set of price IDs to which this adjustment applies. */ fun addAppliesToPriceId(appliesToPriceId: String) = apply { appliesToPriceIds = - (appliesToPriceIds ?: mutableListOf()).apply { add(appliesToPriceId) } + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } - fun maximumAmount(maximumAmount: String) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String) = + maximumAmount(JsonField.of(maximumAmount)) - /** - * When false, this adjustment will be applied to a single price. Otherwise, it - * will be applied at the invoice level, possibly to multiple prices. - */ - fun isInvoiceLevel(isInvoiceLevel: Boolean?) = apply { - this.isInvoiceLevel = isInvoiceLevel + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } /** @@ -25476,15 +33960,15 @@ constructor( * will be applied at the invoice level, possibly to multiple prices. */ fun isInvoiceLevel(isInvoiceLevel: Boolean) = - isInvoiceLevel(isInvoiceLevel as Boolean?) + isInvoiceLevel(JsonField.of(isInvoiceLevel)) /** * When false, this adjustment will be applied to a single price. Otherwise, it * will be applied at the invoice level, possibly to multiple prices. */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun isInvoiceLevel(isInvoiceLevel: Optional) = - isInvoiceLevel(isInvoiceLevel.orElse(null) as Boolean?) + fun isInvoiceLevel(isInvoiceLevel: JsonField) = apply { + this.isInvoiceLevel = isInvoiceLevel + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -25516,7 +34000,7 @@ constructor( checkNotNull(appliesToPriceIds) { "`appliesToPriceIds` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, @@ -25618,60 +34102,137 @@ constructor( class ReplacePrice @JsonCreator private constructor( - @JsonProperty("replaces_price_id") private val replacesPriceId: String, - @JsonProperty("discounts") private val discounts: List?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("minimum_amount") private val minimumAmount: String?, - @JsonProperty("price") private val price: Price?, - @JsonProperty("price_id") private val priceId: String?, + @JsonProperty("replaces_price_id") + @ExcludeMissing + private val replacesPriceId: JsonField = JsonMissing.of(), + @JsonProperty("discounts") + @ExcludeMissing + private val discounts: JsonField> = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("price") + @ExcludeMissing + private val price: JsonField = JsonMissing.of(), + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The id of the price on the plan to replace in the subscription. */ - @JsonProperty("replaces_price_id") fun replacesPriceId(): String = replacesPriceId + fun replacesPriceId(): String = replacesPriceId.getRequired("replaces_price_id") + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + fun discounts(): Optional> = + Optional.ofNullable(discounts.getNullable("discounts")) + + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + fun minimumAmount(): Optional = + Optional.ofNullable(minimumAmount.getNullable("minimum_amount")) + + /** The definition of a new price to create and add to the subscription. */ + fun price(): Optional = Optional.ofNullable(price.getNullable("price")) + + /** The id of the price to add to the subscription. */ + fun priceId(): Optional = Optional.ofNullable(priceId.getNullable("price_id")) + + /** The id of the price on the plan to replace in the subscription. */ + @JsonProperty("replaces_price_id") + @ExcludeMissing + fun _replacesPriceId(): JsonField = replacesPriceId /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the * replacement price. */ @JsonProperty("discounts") - fun discounts(): Optional> = Optional.ofNullable(discounts) + @ExcludeMissing + fun _discounts(): JsonField> = discounts /** The external price id of the price to add to the subscription. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** The new quantity of the price, if the price is a fixed price. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the * replacement price. */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. */ @JsonProperty("minimum_amount") - fun minimumAmount(): Optional = Optional.ofNullable(minimumAmount) + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The definition of a new price to create and add to the subscription. */ - @JsonProperty("price") fun price(): Optional = Optional.ofNullable(price) + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** The id of the price to add to the subscription. */ - @JsonProperty("price_id") fun priceId(): Optional = Optional.ofNullable(priceId) + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ReplacePrice = apply { + if (!validated) { + replacesPriceId() + discounts().map { it.forEach { it.validate() } } + externalPriceId() + fixedPriceQuantity() + maximumAmount() + minimumAmount() + price() + priceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25681,20 +34242,20 @@ constructor( class Builder { - private var replacesPriceId: String? = null - private var discounts: MutableList? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var maximumAmount: String? = null - private var minimumAmount: String? = null - private var price: Price? = null - private var priceId: String? = null + private var replacesPriceId: JsonField? = null + private var discounts: JsonField>? = null + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var maximumAmount: JsonField = JsonMissing.of() + private var minimumAmount: JsonField = JsonMissing.of() + private var price: JsonField = JsonMissing.of() + private var priceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(replacePrice: ReplacePrice) = apply { replacesPriceId = replacePrice.replacesPriceId - discounts = replacePrice.discounts?.toMutableList() + discounts = replacePrice.discounts.map { it.toMutableList() } externalPriceId = replacePrice.externalPriceId fixedPriceQuantity = replacePrice.fixedPriceQuantity maximumAmount = replacePrice.maximumAmount @@ -25705,7 +34266,11 @@ constructor( } /** The id of the price on the plan to replace in the subscription. */ - fun replacesPriceId(replacesPriceId: String) = apply { + fun replacesPriceId(replacesPriceId: String) = + replacesPriceId(JsonField.of(replacesPriceId)) + + /** The id of the price on the plan to replace in the subscription. */ + fun replacesPriceId(replacesPriceId: JsonField) = apply { this.replacesPriceId = replacesPriceId } @@ -25713,9 +34278,7 @@ constructor( * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the * replacement price. */ - fun discounts(discounts: List?) = apply { - this.discounts = discounts?.toMutableList() - } + fun discounts(discounts: List?) = discounts(JsonField.ofNullable(discounts)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the @@ -25723,28 +34286,48 @@ constructor( */ fun discounts(discounts: Optional>) = discounts(discounts.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the + * replacement price. + */ + fun discounts(discounts: JsonField>) = apply { + this.discounts = discounts.map { it.toMutableList() } + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's discounts for the * replacement price. */ fun addDiscount(discount: Discount) = apply { - discounts = (discounts ?: mutableListOf()).apply { add(discount) } + discounts = + (discounts ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discount) + } } /** The external price id of the price to add to the subscription. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** The external price id of the price to add to the subscription. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) - /** The new quantity of the price, if the price is a fixed price. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity + /** The external price id of the price to add to the subscription. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId } + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) + /** The new quantity of the price, if the price is a fixed price. */ fun fixedPriceQuantity(fixedPriceQuantity: Double) = fixedPriceQuantity(fixedPriceQuantity as Double?) @@ -25754,11 +34337,17 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) + /** The new quantity of the price, if the price is a fixed price. */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the * replacement price. */ - fun maximumAmount(maximumAmount: String?) = apply { this.maximumAmount = maximumAmount } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the @@ -25767,11 +34356,20 @@ constructor( fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount for the + * replacement price. + */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount + } + /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the * replacement price. */ - fun minimumAmount(minimumAmount: String?) = apply { this.minimumAmount = minimumAmount } + fun minimumAmount(minimumAmount: String?) = + minimumAmount(JsonField.ofNullable(minimumAmount)) /** * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the @@ -25780,138 +34378,141 @@ constructor( fun minimumAmount(minimumAmount: Optional) = minimumAmount(minimumAmount.orElse(null)) + /** + * [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount for the + * replacement price. + */ + fun minimumAmount(minimumAmount: JsonField) = apply { + this.minimumAmount = minimumAmount + } + /** The definition of a new price to create and add to the subscription. */ - fun price(price: Price?) = apply { this.price = price } + fun price(price: Price?) = price(JsonField.ofNullable(price)) /** The definition of a new price to create and add to the subscription. */ fun price(price: Optional) = price(price.orElse(null)) - fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = apply { - this.price = Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice) - } + /** The definition of a new price to create and add to the subscription. */ + fun price(price: JsonField) = apply { this.price = price } - fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = apply { - this.price = Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice) - } + fun price(newSubscriptionUnitPrice: Price.NewSubscriptionUnitPrice) = + price(Price.ofNewSubscriptionUnitPrice(newSubscriptionUnitPrice)) - fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = apply { - this.price = Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice) - } + fun price(newSubscriptionPackagePrice: Price.NewSubscriptionPackagePrice) = + price(Price.ofNewSubscriptionPackagePrice(newSubscriptionPackagePrice)) - fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = apply { - this.price = Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice) - } + fun price(newSubscriptionMatrixPrice: Price.NewSubscriptionMatrixPrice) = + price(Price.ofNewSubscriptionMatrixPrice(newSubscriptionMatrixPrice)) - fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = apply { - this.price = Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice) - } + fun price(newSubscriptionTieredPrice: Price.NewSubscriptionTieredPrice) = + price(Price.ofNewSubscriptionTieredPrice(newSubscriptionTieredPrice)) - fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice) - } + fun price(newSubscriptionTieredBpsPrice: Price.NewSubscriptionTieredBpsPrice) = + price(Price.ofNewSubscriptionTieredBpsPrice(newSubscriptionTieredBpsPrice)) - fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = apply { - this.price = Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice) - } + fun price(newSubscriptionBpsPrice: Price.NewSubscriptionBpsPrice) = + price(Price.ofNewSubscriptionBpsPrice(newSubscriptionBpsPrice)) - fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = apply { - this.price = Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice) - } + fun price(newSubscriptionBulkBpsPrice: Price.NewSubscriptionBulkBpsPrice) = + price(Price.ofNewSubscriptionBulkBpsPrice(newSubscriptionBulkBpsPrice)) + + fun price(newSubscriptionBulkPrice: Price.NewSubscriptionBulkPrice) = + price(Price.ofNewSubscriptionBulkPrice(newSubscriptionBulkPrice)) fun price( newSubscriptionThresholdTotalAmountPrice: Price.NewSubscriptionThresholdTotalAmountPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionThresholdTotalAmountPrice( newSubscriptionThresholdTotalAmountPrice ) - } + ) fun price(newSubscriptionTieredPackagePrice: Price.NewSubscriptionTieredPackagePrice) = - apply { - this.price = - Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice) - } + price(Price.ofNewSubscriptionTieredPackagePrice(newSubscriptionTieredPackagePrice)) fun price( newSubscriptionTieredWithMinimumPrice: Price.NewSubscriptionTieredWithMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTieredWithMinimumPrice( newSubscriptionTieredWithMinimumPrice ) - } + ) fun price( newSubscriptionUnitWithPercentPrice: Price.NewSubscriptionUnitWithPercentPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithPercentPrice(newSubscriptionUnitWithPercentPrice) - } + ) fun price( newSubscriptionPackageWithAllocationPrice: Price.NewSubscriptionPackageWithAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionPackageWithAllocationPrice( newSubscriptionPackageWithAllocationPrice ) - } + ) fun price( newSubscriptionTierWithProrationPrice: Price.NewSubscriptionTierWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionTierWithProrationPrice( newSubscriptionTierWithProrationPrice ) - } + ) fun price( newSubscriptionUnitWithProrationPrice: Price.NewSubscriptionUnitWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionUnitWithProrationPrice( newSubscriptionUnitWithProrationPrice ) - } + ) fun price( newSubscriptionGroupedAllocationPrice: Price.NewSubscriptionGroupedAllocationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedAllocationPrice( newSubscriptionGroupedAllocationPrice ) - } + ) fun price( newSubscriptionGroupedWithProratedMinimumPrice: Price.NewSubscriptionGroupedWithProratedMinimumPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionGroupedWithProratedMinimumPrice( newSubscriptionGroupedWithProratedMinimumPrice ) - } + ) fun price( newSubscriptionBulkWithProrationPrice: Price.NewSubscriptionBulkWithProrationPrice - ) = apply { - this.price = + ) = + price( Price.ofNewSubscriptionBulkWithProrationPrice( newSubscriptionBulkWithProrationPrice ) - } + ) /** The id of the price to add to the subscription. */ - fun priceId(priceId: String?) = apply { this.priceId = priceId } + fun priceId(priceId: String?) = priceId(JsonField.ofNullable(priceId)) /** The id of the price to add to the subscription. */ fun priceId(priceId: Optional) = priceId(priceId.orElse(null)) + /** The id of the price to add to the subscription. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -25936,7 +34537,7 @@ constructor( checkNotNull(replacesPriceId) { "`replacesPriceId` is required but was not set" }, - discounts?.toImmutable(), + (discounts ?: JsonMissing.of()).map { it.toImmutable() }, externalPriceId, fixedPriceQuantity, maximumAmount, @@ -25951,37 +34552,81 @@ constructor( class Discount @JsonCreator private constructor( - @JsonProperty("discount_type") private val discountType: DiscountType, - @JsonProperty("amount_discount") private val amountDiscount: String?, - @JsonProperty("percentage_discount") private val percentageDiscount: Double?, - @JsonProperty("usage_discount") private val usageDiscount: Double?, + @JsonProperty("discount_type") + @ExcludeMissing + private val discountType: JsonField = JsonMissing.of(), + @JsonProperty("amount_discount") + @ExcludeMissing + private val amountDiscount: JsonField = JsonMissing.of(), + @JsonProperty("percentage_discount") + @ExcludeMissing + private val percentageDiscount: JsonField = JsonMissing.of(), + @JsonProperty("usage_discount") + @ExcludeMissing + private val usageDiscount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("discount_type") fun discountType(): DiscountType = discountType + fun discountType(): DiscountType = discountType.getRequired("discount_type") + + /** Only available if discount_type is `amount`. */ + fun amountDiscount(): Optional = + Optional.ofNullable(amountDiscount.getNullable("amount_discount")) + + /** + * Only available if discount_type is `percentage`. This is a number between 0 and 1. + */ + fun percentageDiscount(): Optional = + Optional.ofNullable(percentageDiscount.getNullable("percentage_discount")) + + /** + * Only available if discount_type is `usage`. Number of usage units that this discount + * is for + */ + fun usageDiscount(): Optional = + Optional.ofNullable(usageDiscount.getNullable("usage_discount")) + + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** Only available if discount_type is `amount`. */ @JsonProperty("amount_discount") - fun amountDiscount(): Optional = Optional.ofNullable(amountDiscount) + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** * Only available if discount_type is `percentage`. This is a number between 0 and 1. */ @JsonProperty("percentage_discount") - fun percentageDiscount(): Optional = Optional.ofNullable(percentageDiscount) + @ExcludeMissing + fun _percentageDiscount(): JsonField = percentageDiscount /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ @JsonProperty("usage_discount") - fun usageDiscount(): Optional = Optional.ofNullable(usageDiscount) + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Discount = apply { + if (!validated) { + discountType() + amountDiscount() + percentageDiscount() + usageDiscount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -25991,10 +34636,10 @@ constructor( class Builder { - private var discountType: DiscountType? = null - private var amountDiscount: String? = null - private var percentageDiscount: Double? = null - private var usageDiscount: Double? = null + private var discountType: JsonField? = null + private var amountDiscount: JsonField = JsonMissing.of() + private var percentageDiscount: JsonField = JsonMissing.of() + private var usageDiscount: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -26006,26 +34651,32 @@ constructor( additionalProperties = discount.additionalProperties.toMutableMap() } - fun discountType(discountType: DiscountType) = apply { + fun discountType(discountType: DiscountType) = + discountType(JsonField.of(discountType)) + + fun discountType(discountType: JsonField) = apply { this.discountType = discountType } /** Only available if discount_type is `amount`. */ - fun amountDiscount(amountDiscount: String?) = apply { - this.amountDiscount = amountDiscount - } + fun amountDiscount(amountDiscount: String?) = + amountDiscount(JsonField.ofNullable(amountDiscount)) /** Only available if discount_type is `amount`. */ fun amountDiscount(amountDiscount: Optional) = amountDiscount(amountDiscount.orElse(null)) + /** Only available if discount_type is `amount`. */ + fun amountDiscount(amountDiscount: JsonField) = apply { + this.amountDiscount = amountDiscount + } + /** * Only available if discount_type is `percentage`. This is a number between 0 * and 1. */ - fun percentageDiscount(percentageDiscount: Double?) = apply { - this.percentageDiscount = percentageDiscount - } + fun percentageDiscount(percentageDiscount: Double?) = + percentageDiscount(JsonField.ofNullable(percentageDiscount)) /** * Only available if discount_type is `percentage`. This is a number between 0 @@ -26042,13 +34693,20 @@ constructor( fun percentageDiscount(percentageDiscount: Optional) = percentageDiscount(percentageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `percentage`. This is a number between 0 + * and 1. + */ + fun percentageDiscount(percentageDiscount: JsonField) = apply { + this.percentageDiscount = percentageDiscount + } + /** * Only available if discount_type is `usage`. Number of usage units that this * discount is for */ - fun usageDiscount(usageDiscount: Double?) = apply { - this.usageDiscount = usageDiscount - } + fun usageDiscount(usageDiscount: Double?) = + usageDiscount(JsonField.ofNullable(usageDiscount)) /** * Only available if discount_type is `usage`. Number of usage units that this @@ -26064,6 +34722,14 @@ constructor( fun usageDiscount(usageDiscount: Optional) = usageDiscount(usageDiscount.orElse(null) as Double?) + /** + * Only available if discount_type is `usage`. Number of usage units that this + * discount is for + */ + fun usageDiscount(usageDiscount: JsonField) = apply { + this.usageDiscount = usageDiscount + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -26221,6 +34887,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun newSubscriptionUnitPrice(): Optional = Optional.ofNullable(newSubscriptionUnitPrice) @@ -26469,6 +35137,52 @@ constructor( } } + fun validate(): Price = apply { + if (!validated) { + if ( + newSubscriptionUnitPrice == null && + newSubscriptionPackagePrice == null && + newSubscriptionMatrixPrice == null && + newSubscriptionTieredPrice == null && + newSubscriptionTieredBpsPrice == null && + newSubscriptionBpsPrice == null && + newSubscriptionBulkBpsPrice == null && + newSubscriptionBulkPrice == null && + newSubscriptionThresholdTotalAmountPrice == null && + newSubscriptionTieredPackagePrice == null && + newSubscriptionTieredWithMinimumPrice == null && + newSubscriptionUnitWithPercentPrice == null && + newSubscriptionPackageWithAllocationPrice == null && + newSubscriptionTierWithProrationPrice == null && + newSubscriptionUnitWithProrationPrice == null && + newSubscriptionGroupedAllocationPrice == null && + newSubscriptionGroupedWithProratedMinimumPrice == null && + newSubscriptionBulkWithProrationPrice == null + ) { + throw OrbInvalidDataException("Unknown Price: $_json") + } + newSubscriptionUnitPrice?.validate() + newSubscriptionPackagePrice?.validate() + newSubscriptionMatrixPrice?.validate() + newSubscriptionTieredPrice?.validate() + newSubscriptionTieredBpsPrice?.validate() + newSubscriptionBpsPrice?.validate() + newSubscriptionBulkBpsPrice?.validate() + newSubscriptionBulkPrice?.validate() + newSubscriptionThresholdTotalAmountPrice?.validate() + newSubscriptionTieredPackagePrice?.validate() + newSubscriptionTieredWithMinimumPrice?.validate() + newSubscriptionUnitWithPercentPrice?.validate() + newSubscriptionPackageWithAllocationPrice?.validate() + newSubscriptionTierWithProrationPrice?.validate() + newSubscriptionUnitWithProrationPrice?.validate() + newSubscriptionGroupedAllocationPrice?.validate() + newSubscriptionGroupedWithProratedMinimumPrice?.validate() + newSubscriptionBulkWithProrationPrice?.validate() + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true @@ -26737,55 +35451,76 @@ constructor( when (modelType) { "unit" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionUnitPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionUnitPrice = it, _json = json) + } } "package" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionPackagePrice = it, _json = json) } } "matrix" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionMatrixPrice = it, _json = json) } } "tiered" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredPrice = it, _json = json) } } "tiered_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionTieredBpsPrice = it, _json = json) } } "bps" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBpsPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBpsPrice = it, _json = json) + } } "bulk_bps" -> { - tryDeserialize(node, jacksonTypeRef()) + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } ?.let { return Price(newSubscriptionBulkBpsPrice = it, _json = json) } } "bulk" -> { - tryDeserialize(node, jacksonTypeRef())?.let { - return Price(newSubscriptionBulkPrice = it, _json = json) - } + tryDeserialize(node, jacksonTypeRef()) { + it.validate() + } + ?.let { + return Price(newSubscriptionBulkPrice = it, _json = json) + } } "threshold_total_amount" -> { tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionThresholdTotalAmountPrice = it, @@ -26797,7 +35532,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredPackagePrice = it, @@ -26809,7 +35546,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTieredWithMinimumPrice = it, @@ -26821,7 +35560,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithPercentPrice = it, @@ -26833,7 +35574,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionPackageWithAllocationPrice = it, @@ -26845,7 +35588,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionTierWithProrationPrice = it, @@ -26857,7 +35602,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionUnitWithProrationPrice = it, @@ -26869,7 +35616,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedAllocationPrice = it, @@ -26881,7 +35630,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionGroupedWithProratedMinimumPrice = it, @@ -26893,7 +35644,9 @@ constructor( tryDeserialize( node, jacksonTypeRef() - ) + ) { + it.validate() + } ?.let { return Price( newSubscriptionBulkWithProrationPrice = it, @@ -26963,96 +35716,229 @@ constructor( class NewSubscriptionUnitPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("unit_config") private val unitConfig: UnitConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("unit_config") + @ExcludeMissing + private val unitConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("unit_config") fun unitConfig(): UnitConfig = unitConfig + fun unitConfig(): UnitConfig = unitConfig.getRequired("unit_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("unit_config") + @ExcludeMissing + fun _unitConfig(): JsonField = unitConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -27060,19 +35946,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27082,22 +35994,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitConfig: UnitConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -27125,25 +36040,41 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } - fun unitConfig(unitConfig: UnitConfig) = apply { this.unitConfig = unitConfig } + fun unitConfig(unitConfig: UnitConfig) = unitConfig(JsonField.of(unitConfig)) + + fun unitConfig(unitConfig: JsonField) = apply { + this.unitConfig = unitConfig + } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -27152,13 +36083,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -27175,13 +36113,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -27191,12 +36137,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -27211,11 +36164,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -27223,22 +36183,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -27255,22 +36224,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -27280,12 +36264,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -27294,11 +36286,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -27307,6 +36307,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -27489,18 +36497,34 @@ constructor( class UnitConfig @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Rate per unit of usage */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Rate per unit of usage */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitConfig = apply { + if (!validated) { + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27510,7 +36534,7 @@ constructor( class Builder { - private var unitAmount: String? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27521,7 +36545,12 @@ constructor( } /** Rate per unit of usage */ - fun unitAmount(unitAmount: String) = apply { this.unitAmount = unitAmount } + fun unitAmount(unitAmount: String) = unitAmount(JsonField.of(unitAmount)) + + /** Rate per unit of usage */ + fun unitAmount(unitAmount: JsonField) = apply { + this.unitAmount = unitAmount + } fun additionalProperties(additionalProperties: Map) = apply { @@ -27580,22 +36609,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27605,8 +36658,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27620,10 +36673,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -27744,22 +36804,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27769,8 +36853,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -27785,10 +36869,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -27918,6 +37009,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -27999,96 +37098,229 @@ constructor( class NewSubscriptionPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("package_config") private val packageConfig: PackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("package_config") + @ExcludeMissing + private val packageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun packageConfig(): PackageConfig = packageConfig.getRequired("package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name - @JsonProperty("package_config") fun packageConfig(): PackageConfig = packageConfig + @JsonProperty("package_config") + @ExcludeMissing + fun _packageConfig(): JsonField = packageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -28096,19 +37328,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28118,22 +37376,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageConfig: PackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -28162,17 +37423,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun packageConfig(packageConfig: PackageConfig) = + packageConfig(JsonField.of(packageConfig)) - fun packageConfig(packageConfig: PackageConfig) = apply { + fun packageConfig(packageConfig: JsonField) = apply { this.packageConfig = packageConfig } @@ -28180,9 +37457,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -28191,13 +37467,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -28214,13 +37497,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -28230,12 +37521,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -28250,11 +37548,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -28262,22 +37567,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -28294,22 +37608,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -28319,12 +37648,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -28333,11 +37670,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -28346,6 +37691,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -28530,25 +37883,52 @@ constructor( class PackageConfig @JsonCreator private constructor( - @JsonProperty("package_amount") private val packageAmount: String, - @JsonProperty("package_size") private val packageSize: Long, + @JsonProperty("package_amount") + @ExcludeMissing + private val packageAmount: JsonField = JsonMissing.of(), + @JsonProperty("package_size") + @ExcludeMissing + private val packageSize: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** A currency amount to rate usage by */ - @JsonProperty("package_amount") fun packageAmount(): String = packageAmount + fun packageAmount(): String = packageAmount.getRequired("package_amount") + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(): Long = packageSize.getRequired("package_size") + + /** A currency amount to rate usage by */ + @JsonProperty("package_amount") + @ExcludeMissing + fun _packageAmount(): JsonField = packageAmount /** * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - @JsonProperty("package_size") fun packageSize(): Long = packageSize + @JsonProperty("package_size") + @ExcludeMissing + fun _packageSize(): JsonField = packageSize @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageConfig = apply { + if (!validated) { + packageAmount() + packageSize() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28558,8 +37938,8 @@ constructor( class Builder { - private var packageAmount: String? = null - private var packageSize: Long? = null + private var packageAmount: JsonField? = null + private var packageSize: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -28571,7 +37951,11 @@ constructor( } /** A currency amount to rate usage by */ - fun packageAmount(packageAmount: String) = apply { + fun packageAmount(packageAmount: String) = + packageAmount(JsonField.of(packageAmount)) + + /** A currency amount to rate usage by */ + fun packageAmount(packageAmount: JsonField) = apply { this.packageAmount = packageAmount } @@ -28579,7 +37963,13 @@ constructor( * An integer amount to represent package size. For example, 1000 here would * divide usage by 1000 before multiplying by package_amount in rating */ - fun packageSize(packageSize: Long) = apply { + fun packageSize(packageSize: Long) = packageSize(JsonField.of(packageSize)) + + /** + * An integer amount to represent package size. For example, 1000 here would + * divide usage by 1000 before multiplying by package_amount in rating + */ + fun packageSize(packageSize: JsonField) = apply { this.packageSize = packageSize } @@ -28643,22 +38033,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28668,8 +38082,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -28683,10 +38097,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -28807,22 +38228,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -28832,8 +38277,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -28848,10 +38293,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -28981,6 +38433,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29062,96 +38522,229 @@ constructor( class NewSubscriptionMatrixPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("matrix_config") private val matrixConfig: MatrixConfig, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("matrix_config") + @ExcludeMissing + private val matrixConfig: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun matrixConfig(): MatrixConfig = matrixConfig.getRequired("matrix_config") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("matrix_config") fun matrixConfig(): MatrixConfig = matrixConfig + @JsonProperty("matrix_config") + @ExcludeMissing + fun _matrixConfig(): JsonField = matrixConfig - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -29159,19 +38752,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionMatrixPrice = apply { + if (!validated) { + cadence() + itemId() + matrixConfig().validate() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29181,22 +38800,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var matrixConfig: MatrixConfig? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var matrixConfig: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -29225,27 +38847,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun matrixConfig(matrixConfig: MatrixConfig) = + matrixConfig(JsonField.of(matrixConfig)) - fun matrixConfig(matrixConfig: MatrixConfig) = apply { + fun matrixConfig(matrixConfig: JsonField) = apply { this.matrixConfig = matrixConfig } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -29254,13 +38891,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -29277,13 +38921,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -29293,12 +38945,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -29313,11 +38972,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -29325,22 +38991,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -29357,22 +39032,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -29382,12 +39072,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -29396,11 +39094,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -29409,6 +39115,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -29541,31 +39255,66 @@ constructor( class MatrixConfig @JsonCreator private constructor( - @JsonProperty("default_unit_amount") private val defaultUnitAmount: String, - @JsonProperty("dimensions") private val dimensions: List, - @JsonProperty("matrix_values") private val matrixValues: List, + @JsonProperty("default_unit_amount") + @ExcludeMissing + private val defaultUnitAmount: JsonField = JsonMissing.of(), + @JsonProperty("dimensions") + @ExcludeMissing + private val dimensions: JsonField> = JsonMissing.of(), + @JsonProperty("matrix_values") + @ExcludeMissing + private val matrixValues: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(): String = + defaultUnitAmount.getRequired("default_unit_amount") + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(): List = dimensions.getRequired("dimensions") + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(): List = + matrixValues.getRequired("matrix_values") + /** * Default per unit rate for any usage not bucketed into a specified * matrix_value */ @JsonProperty("default_unit_amount") - fun defaultUnitAmount(): String = defaultUnitAmount + @ExcludeMissing + fun _defaultUnitAmount(): JsonField = defaultUnitAmount /** One or two event property values to evaluate matrix groups by */ - @JsonProperty("dimensions") fun dimensions(): List = dimensions + @JsonProperty("dimensions") + @ExcludeMissing + fun _dimensions(): JsonField> = dimensions /** Matrix values for specified matrix grouping keys */ @JsonProperty("matrix_values") - fun matrixValues(): List = matrixValues + @ExcludeMissing + fun _matrixValues(): JsonField> = matrixValues @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixConfig = apply { + if (!validated) { + defaultUnitAmount() + dimensions() + matrixValues().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29575,17 +39324,17 @@ constructor( class Builder { - private var defaultUnitAmount: String? = null - private var dimensions: MutableList? = null - private var matrixValues: MutableList? = null + private var defaultUnitAmount: JsonField? = null + private var dimensions: JsonField>? = null + private var matrixValues: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixConfig: MatrixConfig) = apply { defaultUnitAmount = matrixConfig.defaultUnitAmount - dimensions = matrixConfig.dimensions.toMutableList() - matrixValues = matrixConfig.matrixValues.toMutableList() + dimensions = matrixConfig.dimensions.map { it.toMutableList() } + matrixValues = matrixConfig.matrixValues.map { it.toMutableList() } additionalProperties = matrixConfig.additionalProperties.toMutableMap() } @@ -29593,29 +39342,61 @@ constructor( * Default per unit rate for any usage not bucketed into a specified * matrix_value */ - fun defaultUnitAmount(defaultUnitAmount: String) = apply { + fun defaultUnitAmount(defaultUnitAmount: String) = + defaultUnitAmount(JsonField.of(defaultUnitAmount)) + + /** + * Default per unit rate for any usage not bucketed into a specified + * matrix_value + */ + fun defaultUnitAmount(defaultUnitAmount: JsonField) = apply { this.defaultUnitAmount = defaultUnitAmount } /** One or two event property values to evaluate matrix groups by */ - fun dimensions(dimensions: List) = apply { - this.dimensions = dimensions.toMutableList() + fun dimensions(dimensions: List) = + dimensions(JsonField.of(dimensions)) + + /** One or two event property values to evaluate matrix groups by */ + fun dimensions(dimensions: JsonField>) = apply { + this.dimensions = dimensions.map { it.toMutableList() } } /** One or two event property values to evaluate matrix groups by */ fun addDimension(dimension: String) = apply { - dimensions = (dimensions ?: mutableListOf()).apply { add(dimension) } + dimensions = + (dimensions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimension) + } } /** Matrix values for specified matrix grouping keys */ - fun matrixValues(matrixValues: List) = apply { - this.matrixValues = matrixValues.toMutableList() + fun matrixValues(matrixValues: List) = + matrixValues(JsonField.of(matrixValues)) + + /** Matrix values for specified matrix grouping keys */ + fun matrixValues(matrixValues: JsonField>) = apply { + this.matrixValues = matrixValues.map { it.toMutableList() } } /** Matrix values for specified matrix grouping keys */ fun addMatrixValue(matrixValue: MatrixValue) = apply { matrixValues = - (matrixValues ?: mutableListOf()).apply { add(matrixValue) } + (matrixValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(matrixValue) + } } fun additionalProperties(additionalProperties: Map) = @@ -29648,11 +39429,11 @@ constructor( checkNotNull(dimensions) { "`dimensions` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(matrixValues) { "`matrixValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable(), ) } @@ -29662,28 +39443,55 @@ constructor( @JsonCreator private constructor( @JsonProperty("dimension_values") - private val dimensionValues: List, - @JsonProperty("unit_amount") private val unitAmount: String, + @ExcludeMissing + private val dimensionValues: JsonField> = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(): List = + dimensionValues.getRequired("dimension_values") + + /** Unit price for the specified dimension_values */ + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + /** * One or two matrix keys to filter usage to this Matrix value by. For * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ @JsonProperty("dimension_values") - fun dimensionValues(): List = dimensionValues + @ExcludeMissing + fun _dimensionValues(): JsonField> = dimensionValues /** Unit price for the specified dimension_values */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): MatrixValue = apply { + if (!validated) { + dimensionValues() + unitAmount() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29693,14 +39501,15 @@ constructor( class Builder { - private var dimensionValues: MutableList? = null - private var unitAmount: String? = null + private var dimensionValues: JsonField>? = null + private var unitAmount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(matrixValue: MatrixValue) = apply { - dimensionValues = matrixValue.dimensionValues.toMutableList() + dimensionValues = + matrixValue.dimensionValues.map { it.toMutableList() } unitAmount = matrixValue.unitAmount additionalProperties = matrixValue.additionalProperties.toMutableMap() @@ -29711,8 +39520,16 @@ constructor( * example, ["region", "tier"] could be used to filter cloud usage by a * cloud region and an instance tier. */ - fun dimensionValues(dimensionValues: List) = apply { - this.dimensionValues = dimensionValues.toMutableList() + fun dimensionValues(dimensionValues: List) = + dimensionValues(JsonField.of(dimensionValues)) + + /** + * One or two matrix keys to filter usage to this Matrix value by. For + * example, ["region", "tier"] could be used to filter cloud usage by a + * cloud region and an instance tier. + */ + fun dimensionValues(dimensionValues: JsonField>) = apply { + this.dimensionValues = dimensionValues.map { it.toMutableList() } } /** @@ -29722,13 +39539,23 @@ constructor( */ fun addDimensionValue(dimensionValue: String) = apply { dimensionValues = - (dimensionValues ?: mutableListOf()).apply { - add(dimensionValue) + (dimensionValues ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(dimensionValue) } } /** Unit price for the specified dimension_values */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Unit price for the specified dimension_values */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -29759,7 +39586,7 @@ constructor( checkNotNull(dimensionValues) { "`dimensionValues` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, checkNotNull(unitAmount) { "`unitAmount` is required but was not set" }, @@ -29863,22 +39690,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -29888,8 +39739,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -29903,10 +39754,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -30027,22 +39885,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30052,8 +39934,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -30068,10 +39950,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -30201,6 +40090,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30282,96 +40179,229 @@ constructor( class NewSubscriptionTieredPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_config") private val tieredConfig: TieredConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_config") + @ExcludeMissing + private val tieredConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_config") fun tieredConfig(): TieredConfig = tieredConfig + fun tieredConfig(): TieredConfig = tieredConfig.getRequired("tiered_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_config") + @ExcludeMissing + fun _tieredConfig(): JsonField = tieredConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -30379,19 +40409,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30401,22 +40457,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredConfig: TieredConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -30445,17 +40504,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } + + fun tieredConfig(tieredConfig: TieredConfig) = + tieredConfig(JsonField.of(tieredConfig)) - fun tieredConfig(tieredConfig: TieredConfig) = apply { + fun tieredConfig(tieredConfig: JsonField) = apply { this.tieredConfig = tieredConfig } @@ -30463,9 +40538,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -30474,13 +40548,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -30497,13 +40578,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -30513,12 +40602,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -30533,11 +40629,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -30545,22 +40648,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -30577,22 +40689,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -30602,12 +40729,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -30616,11 +40751,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -30629,6 +40772,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -30813,18 +40964,34 @@ constructor( class TieredConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Tiers for rating based on total usage quantities into the specified tier */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Tiers for rating based on total usage quantities into the specified tier */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30834,26 +41001,42 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredConfig: TieredConfig) = apply { - tiers = tieredConfig.tiers.toMutableList() + tiers = tieredConfig.tiers.map { it.toMutableList() } additionalProperties = tieredConfig.additionalProperties.toMutableMap() } /** * Tiers for rating based on total usage quantities into the specified tier */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for rating based on total usage quantities into the specified tier + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for rating based on total usage quantities into the specified tier */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -30881,7 +41064,7 @@ constructor( fun build(): TieredConfig = TieredConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -30890,30 +41073,64 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("first_unit") private val firstUnit: Double, - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("last_unit") private val lastUnit: Double?, + @JsonProperty("first_unit") + @ExcludeMissing + private val firstUnit: JsonField = JsonMissing.of(), + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("last_unit") + @ExcludeMissing + private val lastUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Inclusive tier starting value */ - @JsonProperty("first_unit") fun firstUnit(): Double = firstUnit + fun firstUnit(): Double = firstUnit.getRequired("first_unit") /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** + * Exclusive tier ending value. If null, this is treated as the last tier + */ + fun lastUnit(): Optional = + Optional.ofNullable(lastUnit.getNullable("last_unit")) + + /** Inclusive tier starting value */ + @JsonProperty("first_unit") + @ExcludeMissing + fun _firstUnit(): JsonField = firstUnit + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** * Exclusive tier ending value. If null, this is treated as the last tier */ @JsonProperty("last_unit") - fun lastUnit(): Optional = Optional.ofNullable(lastUnit) + @ExcludeMissing + fun _lastUnit(): JsonField = lastUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + firstUnit() + unitAmount() + lastUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -30923,9 +41140,9 @@ constructor( class Builder { - private var firstUnit: Double? = null - private var unitAmount: String? = null - private var lastUnit: Double? = null + private var firstUnit: JsonField? = null + private var unitAmount: JsonField? = null + private var lastUnit: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -30938,10 +41155,19 @@ constructor( } /** Inclusive tier starting value */ - fun firstUnit(firstUnit: Double) = apply { this.firstUnit = firstUnit } + fun firstUnit(firstUnit: Double) = firstUnit(JsonField.of(firstUnit)) + + /** Inclusive tier starting value */ + fun firstUnit(firstUnit: JsonField) = apply { + this.firstUnit = firstUnit + } + + /** Amount per unit */ + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } @@ -30949,7 +41175,8 @@ constructor( * Exclusive tier ending value. If null, this is treated as the last * tier */ - fun lastUnit(lastUnit: Double?) = apply { this.lastUnit = lastUnit } + fun lastUnit(lastUnit: Double?) = + lastUnit(JsonField.ofNullable(lastUnit)) /** * Exclusive tier ending value. If null, this is treated as the last @@ -30967,6 +41194,14 @@ constructor( fun lastUnit(lastUnit: Optional) = lastUnit(lastUnit.orElse(null) as Double?) + /** + * Exclusive tier ending value. If null, this is treated as the last + * tier + */ + fun lastUnit(lastUnit: JsonField) = apply { + this.lastUnit = lastUnit + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -31046,22 +41281,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31071,8 +41330,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -31086,10 +41345,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -31210,22 +41476,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31235,8 +41525,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -31251,10 +41541,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -31384,6 +41681,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31465,97 +41770,230 @@ constructor( class NewSubscriptionTieredBpsPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("tiered_bps_config") private val tieredBpsConfig: TieredBpsConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("tiered_bps_config") + @ExcludeMissing + private val tieredBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun tieredBpsConfig(): TieredBpsConfig = + tieredBpsConfig.getRequired("tiered_bps_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_bps_config") - fun tieredBpsConfig(): TieredBpsConfig = tieredBpsConfig + @ExcludeMissing + fun _tieredBpsConfig(): JsonField = tieredBpsConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -31563,19 +42001,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredBpsPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredBpsConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -31585,22 +42049,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredBpsConfig: TieredBpsConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredBpsConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -31630,17 +42097,33 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) - fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = apply { + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredBpsConfig(tieredBpsConfig: TieredBpsConfig) = + tieredBpsConfig(JsonField.of(tieredBpsConfig)) + + fun tieredBpsConfig(tieredBpsConfig: JsonField) = apply { this.tieredBpsConfig = tieredBpsConfig } @@ -31648,9 +42131,8 @@ constructor( * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -31659,13 +42141,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -31682,13 +42171,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -31698,12 +42195,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -31718,11 +42222,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -31730,22 +42241,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -31762,22 +42282,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -31787,12 +42322,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -31801,11 +42344,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -31814,6 +42365,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -31998,7 +42557,9 @@ constructor( class TieredBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -32007,12 +42568,29 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32022,13 +42600,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(tieredBpsConfig: TieredBpsConfig) = apply { - tiers = tieredBpsConfig.tiers.toMutableList() + tiers = tieredBpsConfig.tiers.map { it.toMutableList() } additionalProperties = tieredBpsConfig.additionalProperties.toMutableMap() } @@ -32037,14 +42615,31 @@ constructor( * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a Graduated BPS pricing model, where usage is bucketed into + * specified tiers + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a Graduated BPS pricing model, where usage is bucketed into * specified tiers */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -32072,7 +42667,7 @@ constructor( fun build(): TieredBpsConfig = TieredBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -32081,33 +42676,71 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("minimum_amount") private val minimumAmount: String, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("minimum_amount") + @ExcludeMissing + private val minimumAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Per-event basis point rate */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") /** Inclusive tier starting value */ - @JsonProperty("minimum_amount") fun minimumAmount(): String = minimumAmount + fun minimumAmount(): String = minimumAmount.getRequired("minimum_amount") + + /** Exclusive tier ending value */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** Per unit maximum to charge */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Per-event basis point rate */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps + + /** Inclusive tier starting value */ + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** Exclusive tier ending value */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** Per unit maximum to charge */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + minimumAmount() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32117,10 +42750,10 @@ constructor( class Builder { - private var bps: Double? = null - private var minimumAmount: String? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var minimumAmount: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -32134,31 +42767,46 @@ constructor( } /** Per-event basis point rate */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Per-event basis point rate */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Inclusive tier starting value */ - fun minimumAmount(minimumAmount: String) = apply { + fun minimumAmount(minimumAmount: String) = + minimumAmount(JsonField.of(minimumAmount)) + + /** Inclusive tier starting value */ + fun minimumAmount(minimumAmount: JsonField) = apply { this.minimumAmount = minimumAmount } /** Exclusive tier ending value */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Exclusive tier ending value */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** Per unit maximum to charge */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Exclusive tier ending value */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** Per unit maximum to charge */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Per unit maximum to charge */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -32237,22 +42885,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32262,8 +42934,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -32277,10 +42949,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -32401,22 +43080,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32426,8 +43129,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -32442,10 +43145,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -32575,6 +43285,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32656,96 +43374,229 @@ constructor( class NewSubscriptionBpsPrice @JsonCreator private constructor( - @JsonProperty("bps_config") private val bpsConfig: BpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bps_config") + @ExcludeMissing + private val bpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bps_config") fun bpsConfig(): BpsConfig = bpsConfig + fun bpsConfig(): BpsConfig = bpsConfig.getRequired("bps_config") /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bps_config") + @ExcludeMissing + fun _bpsConfig(): JsonField = bpsConfig + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -32753,19 +43604,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBpsPrice = apply { + if (!validated) { + bpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -32775,22 +43652,25 @@ constructor( class Builder { - private var bpsConfig: BpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -32817,26 +43697,42 @@ constructor( newSubscriptionBpsPrice.additionalProperties.toMutableMap() } - fun bpsConfig(bpsConfig: BpsConfig) = apply { this.bpsConfig = bpsConfig } + fun bpsConfig(bpsConfig: BpsConfig) = bpsConfig(JsonField.of(bpsConfig)) + + fun bpsConfig(bpsConfig: JsonField) = apply { + this.bpsConfig = bpsConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -32845,13 +43741,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -32868,13 +43771,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -32884,12 +43795,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -32904,11 +43822,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -32916,22 +43841,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -32948,22 +43882,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -32973,12 +43922,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -32987,11 +43944,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -33000,6 +43965,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -33048,23 +44021,45 @@ constructor( class BpsConfig @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis point take rate per event */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis point take rate per event */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Optional currency amount maximum to cap spend per event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BpsConfig = apply { + if (!validated) { + bps() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33074,8 +44069,8 @@ constructor( class Builder { - private var bps: Double? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -33087,17 +44082,24 @@ constructor( } /** Basis point take rate per event */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis point take rate per event */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Optional currency amount maximum to cap spend per event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum - } + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) /** Optional currency amount maximum to cap spend per event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** Optional currency amount maximum to cap spend per event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -33288,22 +44290,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33313,8 +44339,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -33328,10 +44354,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -33452,22 +44485,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33477,8 +44534,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -33493,10 +44550,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -33626,6 +44690,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33707,96 +44779,229 @@ constructor( class NewSubscriptionBulkBpsPrice @JsonCreator private constructor( - @JsonProperty("bulk_bps_config") private val bulkBpsConfig: BulkBpsConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_bps_config") + @ExcludeMissing + private val bulkBpsConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_bps_config") fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig + fun bulkBpsConfig(): BulkBpsConfig = bulkBpsConfig.getRequired("bulk_bps_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_bps_config") + @ExcludeMissing + fun _bulkBpsConfig(): JsonField = bulkBpsConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -33804,19 +45009,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkBpsPrice = apply { + if (!validated) { + bulkBpsConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -33826,22 +45057,25 @@ constructor( class Builder { - private var bulkBpsConfig: BulkBpsConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkBpsConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -33869,28 +45103,43 @@ constructor( newSubscriptionBulkBpsPrice.additionalProperties.toMutableMap() } - fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = apply { + fun bulkBpsConfig(bulkBpsConfig: BulkBpsConfig) = + bulkBpsConfig(JsonField.of(bulkBpsConfig)) + + fun bulkBpsConfig(bulkBpsConfig: JsonField) = apply { this.bulkBpsConfig = bulkBpsConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -33899,13 +45148,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -33922,13 +45178,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -33938,12 +45202,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -33958,11 +45229,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -33970,22 +45248,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -34002,22 +45289,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -34027,12 +45329,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -34041,11 +45351,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -34054,6 +45372,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -34104,7 +45430,9 @@ constructor( class BulkBpsConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -34113,12 +45441,29 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a single * tier based on total volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a single + * tier based on total volume + */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkBpsConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34128,13 +45473,13 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkBpsConfig: BulkBpsConfig) = apply { - tiers = bulkBpsConfig.tiers.toMutableList() + tiers = bulkBpsConfig.tiers.map { it.toMutableList() } additionalProperties = bulkBpsConfig.additionalProperties.toMutableMap() } @@ -34142,14 +45487,31 @@ constructor( * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** + * Tiers for a bulk BPS pricing model where all usage is aggregated to a + * single tier based on total volume + */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** * Tiers for a bulk BPS pricing model where all usage is aggregated to a * single tier based on total volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -34177,7 +45539,7 @@ constructor( fun build(): BulkBpsConfig = BulkBpsConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -34186,29 +45548,59 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("bps") private val bps: Double, - @JsonProperty("maximum_amount") private val maximumAmount: String?, - @JsonProperty("per_unit_maximum") private val perUnitMaximum: String?, + @JsonProperty("bps") + @ExcludeMissing + private val bps: JsonField = JsonMissing.of(), + @JsonProperty("maximum_amount") + @ExcludeMissing + private val maximumAmount: JsonField = JsonMissing.of(), + @JsonProperty("per_unit_maximum") + @ExcludeMissing + private val perUnitMaximum: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Basis points to rate on */ - @JsonProperty("bps") fun bps(): Double = bps + fun bps(): Double = bps.getRequired("bps") + + /** Upper bound for tier */ + fun maximumAmount(): Optional = + Optional.ofNullable(maximumAmount.getNullable("maximum_amount")) + + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(): Optional = + Optional.ofNullable(perUnitMaximum.getNullable("per_unit_maximum")) + + /** Basis points to rate on */ + @JsonProperty("bps") @ExcludeMissing fun _bps(): JsonField = bps /** Upper bound for tier */ @JsonProperty("maximum_amount") - fun maximumAmount(): Optional = Optional.ofNullable(maximumAmount) + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The maximum amount to charge for any one event */ @JsonProperty("per_unit_maximum") - fun perUnitMaximum(): Optional = Optional.ofNullable(perUnitMaximum) + @ExcludeMissing + fun _perUnitMaximum(): JsonField = perUnitMaximum @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + bps() + maximumAmount() + perUnitMaximum() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34218,9 +45610,9 @@ constructor( class Builder { - private var bps: Double? = null - private var maximumAmount: String? = null - private var perUnitMaximum: String? = null + private var bps: JsonField? = null + private var maximumAmount: JsonField = JsonMissing.of() + private var perUnitMaximum: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -34233,26 +45625,37 @@ constructor( } /** Basis points to rate on */ - fun bps(bps: Double) = apply { this.bps = bps } + fun bps(bps: Double) = bps(JsonField.of(bps)) + + /** Basis points to rate on */ + fun bps(bps: JsonField) = apply { this.bps = bps } /** Upper bound for tier */ - fun maximumAmount(maximumAmount: String?) = apply { - this.maximumAmount = maximumAmount - } + fun maximumAmount(maximumAmount: String?) = + maximumAmount(JsonField.ofNullable(maximumAmount)) /** Upper bound for tier */ fun maximumAmount(maximumAmount: Optional) = maximumAmount(maximumAmount.orElse(null)) - /** The maximum amount to charge for any one event */ - fun perUnitMaximum(perUnitMaximum: String?) = apply { - this.perUnitMaximum = perUnitMaximum + /** Upper bound for tier */ + fun maximumAmount(maximumAmount: JsonField) = apply { + this.maximumAmount = maximumAmount } + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: String?) = + perUnitMaximum(JsonField.ofNullable(perUnitMaximum)) + /** The maximum amount to charge for any one event */ fun perUnitMaximum(perUnitMaximum: Optional) = perUnitMaximum(perUnitMaximum.orElse(null)) + /** The maximum amount to charge for any one event */ + fun perUnitMaximum(perUnitMaximum: JsonField) = apply { + this.perUnitMaximum = perUnitMaximum + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -34462,22 +45865,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34487,8 +45914,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -34502,10 +45929,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -34626,22 +46060,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34651,8 +46109,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -34667,10 +46125,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -34800,6 +46265,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -34881,96 +46354,229 @@ constructor( class NewSubscriptionBulkPrice @JsonCreator private constructor( - @JsonProperty("bulk_config") private val bulkConfig: BulkConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @JsonProperty("bulk_config") + @ExcludeMissing + private val bulkConfig: JsonField = JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { - @JsonProperty("bulk_config") fun bulkConfig(): BulkConfig = bulkConfig + fun bulkConfig(): BulkConfig = bulkConfig.getRequired("bulk_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + @JsonProperty("bulk_config") + @ExcludeMissing + fun _bulkConfig(): JsonField = bulkConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -34978,19 +46584,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkPrice = apply { + if (!validated) { + bulkConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35000,22 +46632,25 @@ constructor( class Builder { - private var bulkConfig: BulkConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -35042,26 +46677,42 @@ constructor( newSubscriptionBulkPrice.additionalProperties.toMutableMap() } - fun bulkConfig(bulkConfig: BulkConfig) = apply { this.bulkConfig = bulkConfig } + fun bulkConfig(bulkConfig: BulkConfig) = bulkConfig(JsonField.of(bulkConfig)) + + fun bulkConfig(bulkConfig: JsonField) = apply { + this.bulkConfig = bulkConfig + } + + /** The cadence to bill for this price on. */ + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -35070,13 +46721,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -35093,13 +46751,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -35109,12 +46775,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -35129,11 +46802,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -35141,22 +46821,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -35173,22 +46862,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -35198,12 +46902,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -35212,11 +46924,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -35225,6 +46945,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -35273,18 +47001,34 @@ constructor( class BulkConfig @JsonCreator private constructor( - @JsonProperty("tiers") private val tiers: List, + @JsonProperty("tiers") + @ExcludeMissing + private val tiers: JsonField> = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Bulk tiers for rating based on total usage volume */ - @JsonProperty("tiers") fun tiers(): List = tiers + fun tiers(): List = tiers.getRequired("tiers") + + /** Bulk tiers for rating based on total usage volume */ + @JsonProperty("tiers") + @ExcludeMissing + fun _tiers(): JsonField> = tiers @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkConfig = apply { + if (!validated) { + tiers().forEach { it.validate() } + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35294,22 +47038,36 @@ constructor( class Builder { - private var tiers: MutableList? = null + private var tiers: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(bulkConfig: BulkConfig) = apply { - tiers = bulkConfig.tiers.toMutableList() + tiers = bulkConfig.tiers.map { it.toMutableList() } additionalProperties = bulkConfig.additionalProperties.toMutableMap() } /** Bulk tiers for rating based on total usage volume */ - fun tiers(tiers: List) = apply { this.tiers = tiers.toMutableList() } + fun tiers(tiers: List) = tiers(JsonField.of(tiers)) + + /** Bulk tiers for rating based on total usage volume */ + fun tiers(tiers: JsonField>) = apply { + this.tiers = tiers.map { it.toMutableList() } + } /** Bulk tiers for rating based on total usage volume */ fun addTier(tier: Tier) = apply { - tiers = (tiers ?: mutableListOf()).apply { add(tier) } + tiers = + (tiers ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(tier) + } } fun additionalProperties(additionalProperties: Map) = @@ -35337,7 +47095,7 @@ constructor( fun build(): BulkConfig = BulkConfig( checkNotNull(tiers) { "`tiers` is required but was not set" } - .toImmutable(), + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -35346,24 +47104,48 @@ constructor( class Tier @JsonCreator private constructor( - @JsonProperty("unit_amount") private val unitAmount: String, - @JsonProperty("maximum_units") private val maximumUnits: Double?, + @JsonProperty("unit_amount") + @ExcludeMissing + private val unitAmount: JsonField = JsonMissing.of(), + @JsonProperty("maximum_units") + @ExcludeMissing + private val maximumUnits: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Amount per unit */ - @JsonProperty("unit_amount") fun unitAmount(): String = unitAmount + fun unitAmount(): String = unitAmount.getRequired("unit_amount") + + /** Upper bound for this tier */ + fun maximumUnits(): Optional = + Optional.ofNullable(maximumUnits.getNullable("maximum_units")) + + /** Amount per unit */ + @JsonProperty("unit_amount") + @ExcludeMissing + fun _unitAmount(): JsonField = unitAmount /** Upper bound for this tier */ @JsonProperty("maximum_units") - fun maximumUnits(): Optional = Optional.ofNullable(maximumUnits) + @ExcludeMissing + fun _maximumUnits(): JsonField = maximumUnits @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Tier = apply { + if (!validated) { + unitAmount() + maximumUnits() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35373,8 +47155,8 @@ constructor( class Builder { - private var unitAmount: String? = null - private var maximumUnits: Double? = null + private var unitAmount: JsonField? = null + private var maximumUnits: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -35386,14 +47168,17 @@ constructor( } /** Amount per unit */ - fun unitAmount(unitAmount: String) = apply { + fun unitAmount(unitAmount: String) = + unitAmount(JsonField.of(unitAmount)) + + /** Amount per unit */ + fun unitAmount(unitAmount: JsonField) = apply { this.unitAmount = unitAmount } /** Upper bound for this tier */ - fun maximumUnits(maximumUnits: Double?) = apply { - this.maximumUnits = maximumUnits - } + fun maximumUnits(maximumUnits: Double?) = + maximumUnits(JsonField.ofNullable(maximumUnits)) /** Upper bound for this tier */ fun maximumUnits(maximumUnits: Double) = @@ -35406,6 +47191,11 @@ constructor( fun maximumUnits(maximumUnits: Optional) = maximumUnits(maximumUnits.orElse(null) as Double?) + /** Upper bound for this tier */ + fun maximumUnits(maximumUnits: JsonField) = apply { + this.maximumUnits = maximumUnits + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -35616,22 +47406,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35641,8 +47455,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -35656,10 +47470,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -35780,22 +47601,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -35805,8 +47650,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -35821,10 +47666,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -35954,6 +47806,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36035,42 +47895,166 @@ constructor( class NewSubscriptionThresholdTotalAmountPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("threshold_total_amount_config") - private val thresholdTotalAmountConfig: ThresholdTotalAmountConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val thresholdTotalAmountConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("threshold_total_amount_config") fun thresholdTotalAmountConfig(): ThresholdTotalAmountConfig = + thresholdTotalAmountConfig.getRequired("threshold_total_amount_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("threshold_total_amount_config") + @ExcludeMissing + fun _thresholdTotalAmountConfig(): JsonField = thresholdTotalAmountConfig /** @@ -36078,56 +48062,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -36135,19 +48128,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionThresholdTotalAmountPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + thresholdTotalAmountConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36157,22 +48176,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var thresholdTotalAmountConfig: ThresholdTotalAmountConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var thresholdTotalAmountConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -36207,27 +48230,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun thresholdTotalAmountConfig( thresholdTotalAmountConfig: ThresholdTotalAmountConfig + ) = thresholdTotalAmountConfig(JsonField.of(thresholdTotalAmountConfig)) + + fun thresholdTotalAmountConfig( + thresholdTotalAmountConfig: JsonField ) = apply { this.thresholdTotalAmountConfig = thresholdTotalAmountConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -36236,13 +48275,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -36259,13 +48305,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -36275,12 +48329,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -36295,11 +48356,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -36307,22 +48375,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -36339,22 +48416,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -36364,12 +48456,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -36378,11 +48478,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -36391,6 +48499,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -36583,6 +48699,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): ThresholdTotalAmountConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36654,22 +48778,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36679,8 +48827,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -36694,10 +48842,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -36818,22 +48973,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -36843,8 +49022,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -36859,10 +49038,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -36992,6 +49178,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37073,98 +49267,230 @@ constructor( class NewSubscriptionTieredPackagePrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_package_config") - private val tieredPackageConfig: TieredPackageConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredPackageConfig: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredPackageConfig(): TieredPackageConfig = + tieredPackageConfig.getRequired("tiered_package_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_package_config") - fun tieredPackageConfig(): TieredPackageConfig = tieredPackageConfig + @ExcludeMissing + fun _tieredPackageConfig(): JsonField = tieredPackageConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -37172,19 +49498,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredPackagePrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredPackageConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37194,22 +49546,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredPackageConfig: TieredPackageConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredPackageConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -37239,27 +49594,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = apply { - this.tieredPackageConfig = tieredPackageConfig + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } + + fun tieredPackageConfig(tieredPackageConfig: TieredPackageConfig) = + tieredPackageConfig(JsonField.of(tieredPackageConfig)) + + fun tieredPackageConfig(tieredPackageConfig: JsonField) = + apply { + this.tieredPackageConfig = tieredPackageConfig + } + /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -37268,13 +49639,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -37291,13 +49669,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -37307,12 +49693,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -37327,11 +49720,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -37339,22 +49739,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -37371,22 +49780,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -37396,12 +49820,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -37410,11 +49842,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -37423,6 +49863,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -37615,6 +50063,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredPackageConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37685,22 +50141,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37710,8 +50190,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -37725,10 +50205,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -37849,22 +50336,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -37874,8 +50385,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -37890,10 +50401,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -38023,6 +50541,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38104,98 +50630,232 @@ constructor( class NewSubscriptionTieredWithMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_minimum_config") - private val tieredWithMinimumConfig: TieredWithMinimumConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithMinimumConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + fun tieredWithMinimumConfig(): TieredWithMinimumConfig = + tieredWithMinimumConfig.getRequired("tiered_with_minimum_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("tiered_with_minimum_config") - fun tieredWithMinimumConfig(): TieredWithMinimumConfig = tieredWithMinimumConfig + @ExcludeMissing + fun _tieredWithMinimumConfig(): JsonField = + tieredWithMinimumConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -38203,19 +50863,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTieredWithMinimumPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithMinimumConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38225,22 +50911,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithMinimumConfig: TieredWithMinimumConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithMinimumConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -38274,28 +50963,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } fun tieredWithMinimumConfig(tieredWithMinimumConfig: TieredWithMinimumConfig) = - apply { - this.tieredWithMinimumConfig = tieredWithMinimumConfig - } + tieredWithMinimumConfig(JsonField.of(tieredWithMinimumConfig)) + + fun tieredWithMinimumConfig( + tieredWithMinimumConfig: JsonField + ) = apply { this.tieredWithMinimumConfig = tieredWithMinimumConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -38304,13 +51007,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -38327,13 +51037,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -38343,12 +51061,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -38363,11 +51088,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -38375,22 +51107,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -38407,22 +51148,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -38432,12 +51188,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -38446,11 +51210,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -38459,6 +51231,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -38651,6 +51431,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38722,22 +51510,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38747,8 +51559,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -38762,10 +51574,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -38886,22 +51705,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -38911,8 +51754,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -38927,10 +51770,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -39060,6 +51910,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39141,98 +51999,232 @@ constructor( class NewSubscriptionUnitWithPercentPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_percent_config") - private val unitWithPercentConfig: UnitWithPercentConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithPercentConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun unitWithPercentConfig(): UnitWithPercentConfig = + unitWithPercentConfig.getRequired("unit_with_percent_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_percent_config") - fun unitWithPercentConfig(): UnitWithPercentConfig = unitWithPercentConfig + @ExcludeMissing + fun _unitWithPercentConfig(): JsonField = + unitWithPercentConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -39240,19 +52232,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithPercentPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithPercentConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39262,22 +52280,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithPercentConfig: UnitWithPercentConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithPercentConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -39308,28 +52329,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithPercentConfig(unitWithPercentConfig: UnitWithPercentConfig) = - apply { - this.unitWithPercentConfig = unitWithPercentConfig - } + unitWithPercentConfig(JsonField.of(unitWithPercentConfig)) + + fun unitWithPercentConfig( + unitWithPercentConfig: JsonField + ) = apply { this.unitWithPercentConfig = unitWithPercentConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -39338,13 +52373,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -39361,13 +52403,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -39377,12 +52427,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -39397,11 +52454,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -39409,22 +52473,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -39441,22 +52514,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -39466,12 +52554,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -39480,11 +52576,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -39493,6 +52597,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -39685,6 +52797,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithPercentConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39755,22 +52875,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39780,8 +52924,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -39795,10 +52939,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -39919,22 +53070,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -39944,8 +53119,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -39960,10 +53135,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -40093,6 +53275,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40174,42 +53364,166 @@ constructor( class NewSubscriptionPackageWithAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("package_with_allocation_config") - private val packageWithAllocationConfig: PackageWithAllocationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val packageWithAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("package_with_allocation_config") fun packageWithAllocationConfig(): PackageWithAllocationConfig = + packageWithAllocationConfig.getRequired("package_with_allocation_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("package_with_allocation_config") + @ExcludeMissing + fun _packageWithAllocationConfig(): JsonField = packageWithAllocationConfig /** @@ -40217,56 +53531,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -40274,19 +53597,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionPackageWithAllocationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + packageWithAllocationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40296,22 +53645,27 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var packageWithAllocationConfig: PackageWithAllocationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var packageWithAllocationConfig: + JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -40347,27 +53701,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun packageWithAllocationConfig( packageWithAllocationConfig: PackageWithAllocationConfig + ) = packageWithAllocationConfig(JsonField.of(packageWithAllocationConfig)) + + fun packageWithAllocationConfig( + packageWithAllocationConfig: JsonField ) = apply { this.packageWithAllocationConfig = packageWithAllocationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -40376,13 +53746,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -40399,13 +53776,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -40415,12 +53800,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -40435,11 +53827,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -40447,22 +53846,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -40479,22 +53887,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -40504,12 +53927,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -40518,11 +53949,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -40531,6 +53970,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -40723,6 +54170,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): PackageWithAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40795,22 +54250,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40820,8 +54299,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -40835,10 +54314,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -40959,22 +54445,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -40984,8 +54494,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -41000,10 +54510,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -41133,6 +54650,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41214,42 +54739,166 @@ constructor( class NewSubscriptionTierWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("tiered_with_proration_config") - private val tieredWithProrationConfig: TieredWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val tieredWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") - @JsonProperty("tiered_with_proration_config") fun tieredWithProrationConfig(): TieredWithProrationConfig = + tieredWithProrationConfig.getRequired("tiered_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name + + @JsonProperty("tiered_with_proration_config") + @ExcludeMissing + fun _tieredWithProrationConfig(): JsonField = tieredWithProrationConfig /** @@ -41257,56 +54906,65 @@ constructor( * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -41314,19 +54972,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionTierWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + tieredWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41336,22 +55020,26 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var tieredWithProrationConfig: TieredWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var tieredWithProrationConfig: JsonField? = + null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -41385,27 +55073,43 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun tieredWithProrationConfig( tieredWithProrationConfig: TieredWithProrationConfig + ) = tieredWithProrationConfig(JsonField.of(tieredWithProrationConfig)) + + fun tieredWithProrationConfig( + tieredWithProrationConfig: JsonField ) = apply { this.tieredWithProrationConfig = tieredWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -41414,13 +55118,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -41437,13 +55148,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -41453,12 +55172,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -41473,11 +55199,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -41485,22 +55218,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -41517,22 +55259,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -41542,12 +55299,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -41556,11 +55321,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -41569,6 +55342,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -41761,6 +55542,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): TieredWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41832,22 +55621,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -41857,8 +55670,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -41872,10 +55685,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -41996,22 +55816,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42021,8 +55865,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -42037,10 +55881,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -42170,6 +56021,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42251,98 +56110,232 @@ constructor( class NewSubscriptionUnitWithProrationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), @JsonProperty("unit_with_proration_config") - private val unitWithProrationConfig: UnitWithProrationConfig, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val unitWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + fun itemId(): String = itemId.getRequired("item_id") - @JsonProperty("model_type") fun modelType(): ModelType = modelType + fun modelType(): ModelType = modelType.getRequired("model_type") /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + fun name(): String = name.getRequired("name") + + fun unitWithProrationConfig(): UnitWithProrationConfig = + unitWithProrationConfig.getRequired("unit_with_proration_config") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + /** The id of the item the plan will be associated with. */ + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId + + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType + + /** The name of the price. */ + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonProperty("unit_with_proration_config") - fun unitWithProrationConfig(): UnitWithProrationConfig = unitWithProrationConfig + @ExcludeMissing + fun _unitWithProrationConfig(): JsonField = + unitWithProrationConfig /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -42350,19 +56343,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionUnitWithProrationPrice = apply { + if (!validated) { + cadence() + itemId() + modelType() + name() + unitWithProrationConfig().validate() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42372,22 +56391,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var unitWithProrationConfig: UnitWithProrationConfig? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var unitWithProrationConfig: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -42421,28 +56443,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } fun unitWithProrationConfig(unitWithProrationConfig: UnitWithProrationConfig) = - apply { - this.unitWithProrationConfig = unitWithProrationConfig - } + unitWithProrationConfig(JsonField.of(unitWithProrationConfig)) + + fun unitWithProrationConfig( + unitWithProrationConfig: JsonField + ) = apply { this.unitWithProrationConfig = unitWithProrationConfig } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -42451,13 +56487,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -42474,13 +56517,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -42490,12 +56541,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -42510,11 +56568,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -42522,22 +56587,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -42554,22 +56628,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -42579,12 +56668,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -42593,11 +56690,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -42606,6 +56711,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -42798,6 +56911,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): UnitWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42869,22 +56990,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -42894,8 +57039,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -42909,10 +57054,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -43033,22 +57185,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43058,8 +57234,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -43074,10 +57250,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -43207,6 +57390,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43288,98 +57479,232 @@ constructor( class NewSubscriptionGroupedAllocationPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_allocation_config") - private val groupedAllocationConfig: GroupedAllocationConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedAllocationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") + + fun groupedAllocationConfig(): GroupedAllocationConfig = + groupedAllocationConfig.getRequired("grouped_allocation_config") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence @JsonProperty("grouped_allocation_config") - fun groupedAllocationConfig(): GroupedAllocationConfig = groupedAllocationConfig + @ExcludeMissing + fun _groupedAllocationConfig(): JsonField = + groupedAllocationConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -43387,19 +57712,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedAllocationPrice = apply { + if (!validated) { + cadence() + groupedAllocationConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43409,22 +57760,25 @@ constructor( class Builder { - private var cadence: Cadence? = null - private var groupedAllocationConfig: GroupedAllocationConfig? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var cadence: JsonField? = null + private var groupedAllocationConfig: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -43458,28 +57812,42 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedAllocationConfig(groupedAllocationConfig: GroupedAllocationConfig) = - apply { - this.groupedAllocationConfig = groupedAllocationConfig - } + groupedAllocationConfig(JsonField.of(groupedAllocationConfig)) + + fun groupedAllocationConfig( + groupedAllocationConfig: JsonField + ) = apply { this.groupedAllocationConfig = groupedAllocationConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -43488,13 +57856,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -43511,13 +57886,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -43527,12 +57910,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -43547,11 +57937,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -43559,22 +57956,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -43591,22 +57997,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -43616,12 +58037,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -43630,11 +58059,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -43643,6 +58080,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -43783,6 +58228,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedAllocationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43906,22 +58359,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -43931,8 +58408,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -43946,10 +58423,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -44070,22 +58554,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44095,8 +58603,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -44111,10 +58619,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -44244,6 +58759,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44325,99 +58848,235 @@ constructor( class NewSubscriptionGroupedWithProratedMinimumPrice @JsonCreator private constructor( - @JsonProperty("cadence") private val cadence: Cadence, + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), @JsonProperty("grouped_with_prorated_minimum_config") - private val groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val groupedWithProratedMinimumConfig: + JsonField = + JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + fun cadence(): Cadence = cadence.getRequired("cadence") - @JsonProperty("grouped_with_prorated_minimum_config") fun groupedWithProratedMinimumConfig(): GroupedWithProratedMinimumConfig = - groupedWithProratedMinimumConfig + groupedWithProratedMinimumConfig.getRequired( + "grouped_with_prorated_minimum_config" + ) + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + + /** The cadence to bill for this price on. */ + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence + + @JsonProperty("grouped_with_prorated_minimum_config") + @ExcludeMissing + fun _groupedWithProratedMinimumConfig(): + JsonField = groupedWithProratedMinimumConfig /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -44425,19 +59084,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionGroupedWithProratedMinimumPrice = apply { + if (!validated) { + cadence() + groupedWithProratedMinimumConfig().validate() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44447,24 +59132,27 @@ constructor( class Builder { - private var cadence: Cadence? = null + private var cadence: JsonField? = null private var groupedWithProratedMinimumConfig: - GroupedWithProratedMinimumConfig? = + JsonField? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -44505,29 +59193,49 @@ constructor( } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } fun groupedWithProratedMinimumConfig( groupedWithProratedMinimumConfig: GroupedWithProratedMinimumConfig + ) = + groupedWithProratedMinimumConfig( + JsonField.of(groupedWithProratedMinimumConfig) + ) + + fun groupedWithProratedMinimumConfig( + groupedWithProratedMinimumConfig: + JsonField ) = apply { this.groupedWithProratedMinimumConfig = groupedWithProratedMinimumConfig } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) + + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: String) = name(JsonField.of(name)) + + /** The name of the price. */ + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -44536,13 +59244,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -44559,13 +59274,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -44575,12 +59298,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -44595,11 +59325,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -44607,22 +59344,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -44639,22 +59385,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -44664,12 +59425,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -44678,11 +59447,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -44691,6 +59468,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -44831,6 +59616,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): GroupedWithProratedMinimumConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44956,22 +59749,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -44981,8 +59798,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -44996,10 +59813,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -45120,22 +59944,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration + + /** The unit of billing period duration. */ + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45145,8 +59993,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -45161,10 +60009,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -45294,6 +60149,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45376,97 +60239,231 @@ constructor( @JsonCreator private constructor( @JsonProperty("bulk_with_proration_config") - private val bulkWithProrationConfig: BulkWithProrationConfig, - @JsonProperty("cadence") private val cadence: Cadence, - @JsonProperty("item_id") private val itemId: String, - @JsonProperty("model_type") private val modelType: ModelType, - @JsonProperty("name") private val name: String, - @JsonProperty("billable_metric_id") private val billableMetricId: String?, - @JsonProperty("billed_in_advance") private val billedInAdvance: Boolean?, + @ExcludeMissing + private val bulkWithProrationConfig: JsonField = + JsonMissing.of(), + @JsonProperty("cadence") + @ExcludeMissing + private val cadence: JsonField = JsonMissing.of(), + @JsonProperty("item_id") + @ExcludeMissing + private val itemId: JsonField = JsonMissing.of(), + @JsonProperty("model_type") + @ExcludeMissing + private val modelType: JsonField = JsonMissing.of(), + @JsonProperty("name") + @ExcludeMissing + private val name: JsonField = JsonMissing.of(), + @JsonProperty("billable_metric_id") + @ExcludeMissing + private val billableMetricId: JsonField = JsonMissing.of(), + @JsonProperty("billed_in_advance") + @ExcludeMissing + private val billedInAdvance: JsonField = JsonMissing.of(), @JsonProperty("billing_cycle_configuration") - private val billingCycleConfiguration: BillingCycleConfiguration?, - @JsonProperty("conversion_rate") private val conversionRate: Double?, - @JsonProperty("currency") private val currency: String?, - @JsonProperty("external_price_id") private val externalPriceId: String?, - @JsonProperty("fixed_price_quantity") private val fixedPriceQuantity: Double?, - @JsonProperty("invoice_grouping_key") private val invoiceGroupingKey: String?, + @ExcludeMissing + private val billingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("conversion_rate") + @ExcludeMissing + private val conversionRate: JsonField = JsonMissing.of(), + @JsonProperty("currency") + @ExcludeMissing + private val currency: JsonField = JsonMissing.of(), + @JsonProperty("external_price_id") + @ExcludeMissing + private val externalPriceId: JsonField = JsonMissing.of(), + @JsonProperty("fixed_price_quantity") + @ExcludeMissing + private val fixedPriceQuantity: JsonField = JsonMissing.of(), + @JsonProperty("invoice_grouping_key") + @ExcludeMissing + private val invoiceGroupingKey: JsonField = JsonMissing.of(), @JsonProperty("invoicing_cycle_configuration") - private val invoicingCycleConfiguration: InvoicingCycleConfiguration?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("reference_id") private val referenceId: String?, + @ExcludeMissing + private val invoicingCycleConfiguration: JsonField = + JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("reference_id") + @ExcludeMissing + private val referenceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + fun bulkWithProrationConfig(): BulkWithProrationConfig = + bulkWithProrationConfig.getRequired("bulk_with_proration_config") + + /** The cadence to bill for this price on. */ + fun cadence(): Cadence = cadence.getRequired("cadence") + + /** The id of the item the plan will be associated with. */ + fun itemId(): String = itemId.getRequired("item_id") + + fun modelType(): ModelType = modelType.getRequired("model_type") + + /** The name of the price. */ + fun name(): String = name.getRequired("name") + + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(): Optional = + Optional.ofNullable(billableMetricId.getNullable("billable_metric_id")) + + /** + * If the Price represents a fixed cost, the price will be billed in-advance if this + * is true, and in-arrears if this is false. + */ + fun billedInAdvance(): Optional = + Optional.ofNullable(billedInAdvance.getNullable("billed_in_advance")) + + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration(): Optional = + Optional.ofNullable( + billingCycleConfiguration.getNullable("billing_cycle_configuration") + ) + + /** The per unit conversion rate of the price currency to the invoicing currency. */ + fun conversionRate(): Optional = + Optional.ofNullable(conversionRate.getNullable("conversion_rate")) + + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(): Optional = + Optional.ofNullable(currency.getNullable("currency")) + + /** An alias for the price. */ + fun externalPriceId(): Optional = + Optional.ofNullable(externalPriceId.getNullable("external_price_id")) + + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(): Optional = + Optional.ofNullable(fixedPriceQuantity.getNullable("fixed_price_quantity")) + + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(): Optional = + Optional.ofNullable(invoiceGroupingKey.getNullable("invoice_grouping_key")) + + /** + * Within each billing cycle, specifies the cadence at which invoices are produced. + * If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration(): Optional = + Optional.ofNullable( + invoicingCycleConfiguration.getNullable("invoicing_cycle_configuration") + ) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed + * by setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(): Optional = + Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * A transient ID that can be used to reference this price when adding adjustments + * in the same API call. + */ + fun referenceId(): Optional = + Optional.ofNullable(referenceId.getNullable("reference_id")) + @JsonProperty("bulk_with_proration_config") - fun bulkWithProrationConfig(): BulkWithProrationConfig = bulkWithProrationConfig + @ExcludeMissing + fun _bulkWithProrationConfig(): JsonField = + bulkWithProrationConfig /** The cadence to bill for this price on. */ - @JsonProperty("cadence") fun cadence(): Cadence = cadence + @JsonProperty("cadence") + @ExcludeMissing + fun _cadence(): JsonField = cadence /** The id of the item the plan will be associated with. */ - @JsonProperty("item_id") fun itemId(): String = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId - @JsonProperty("model_type") fun modelType(): ModelType = modelType + @JsonProperty("model_type") + @ExcludeMissing + fun _modelType(): JsonField = modelType /** The name of the price. */ - @JsonProperty("name") fun name(): String = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ @JsonProperty("billable_metric_id") - fun billableMetricId(): Optional = Optional.ofNullable(billableMetricId) + @ExcludeMissing + fun _billableMetricId(): JsonField = billableMetricId /** * If the Price represents a fixed cost, the price will be billed in-advance if this * is true, and in-arrears if this is false. */ @JsonProperty("billed_in_advance") - fun billedInAdvance(): Optional = Optional.ofNullable(billedInAdvance) + @ExcludeMissing + fun _billedInAdvance(): JsonField = billedInAdvance /** * For custom cadence: specifies the duration of the billing period in days or * months. */ @JsonProperty("billing_cycle_configuration") - fun billingCycleConfiguration(): Optional = - Optional.ofNullable(billingCycleConfiguration) + @ExcludeMissing + fun _billingCycleConfiguration(): JsonField = + billingCycleConfiguration /** The per unit conversion rate of the price currency to the invoicing currency. */ @JsonProperty("conversion_rate") - fun conversionRate(): Optional = Optional.ofNullable(conversionRate) + @ExcludeMissing + fun _conversionRate(): JsonField = conversionRate /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ @JsonProperty("currency") - fun currency(): Optional = Optional.ofNullable(currency) + @ExcludeMissing + fun _currency(): JsonField = currency /** An alias for the price. */ @JsonProperty("external_price_id") - fun externalPriceId(): Optional = Optional.ofNullable(externalPriceId) + @ExcludeMissing + fun _externalPriceId(): JsonField = externalPriceId /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ @JsonProperty("fixed_price_quantity") - fun fixedPriceQuantity(): Optional = Optional.ofNullable(fixedPriceQuantity) + @ExcludeMissing + fun _fixedPriceQuantity(): JsonField = fixedPriceQuantity /** The property used to group this price on an invoice */ @JsonProperty("invoice_grouping_key") - fun invoiceGroupingKey(): Optional = Optional.ofNullable(invoiceGroupingKey) + @ExcludeMissing + fun _invoiceGroupingKey(): JsonField = invoiceGroupingKey /** * Within each billing cycle, specifies the cadence at which invoices are produced. * If unspecified, a single invoice is produced per billing cycle. */ @JsonProperty("invoicing_cycle_configuration") - fun invoicingCycleConfiguration(): Optional = - Optional.ofNullable(invoicingCycleConfiguration) + @ExcludeMissing + fun _invoicingCycleConfiguration(): JsonField = + invoicingCycleConfiguration /** * User-specified key/value pairs for the resource. Individual keys can be removed @@ -45474,19 +60471,45 @@ constructor( * setting `metadata` to `null`. */ @JsonProperty("metadata") - fun metadata(): Optional = Optional.ofNullable(metadata) + @ExcludeMissing + fun _metadata(): JsonField = metadata /** * A transient ID that can be used to reference this price when adding adjustments * in the same API call. */ @JsonProperty("reference_id") - fun referenceId(): Optional = Optional.ofNullable(referenceId) + @ExcludeMissing + fun _referenceId(): JsonField = referenceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): NewSubscriptionBulkWithProrationPrice = apply { + if (!validated) { + bulkWithProrationConfig().validate() + cadence() + itemId() + modelType() + name() + billableMetricId() + billedInAdvance() + billingCycleConfiguration().map { it.validate() } + conversionRate() + currency() + externalPriceId() + fixedPriceQuantity() + invoiceGroupingKey() + invoicingCycleConfiguration().map { it.validate() } + metadata().map { it.validate() } + referenceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45496,22 +60519,25 @@ constructor( class Builder { - private var bulkWithProrationConfig: BulkWithProrationConfig? = null - private var cadence: Cadence? = null - private var itemId: String? = null - private var modelType: ModelType? = null - private var name: String? = null - private var billableMetricId: String? = null - private var billedInAdvance: Boolean? = null - private var billingCycleConfiguration: BillingCycleConfiguration? = null - private var conversionRate: Double? = null - private var currency: String? = null - private var externalPriceId: String? = null - private var fixedPriceQuantity: Double? = null - private var invoiceGroupingKey: String? = null - private var invoicingCycleConfiguration: InvoicingCycleConfiguration? = null - private var metadata: Metadata? = null - private var referenceId: String? = null + private var bulkWithProrationConfig: JsonField? = null + private var cadence: JsonField? = null + private var itemId: JsonField? = null + private var modelType: JsonField? = null + private var name: JsonField? = null + private var billableMetricId: JsonField = JsonMissing.of() + private var billedInAdvance: JsonField = JsonMissing.of() + private var billingCycleConfiguration: JsonField = + JsonMissing.of() + private var conversionRate: JsonField = JsonMissing.of() + private var currency: JsonField = JsonMissing.of() + private var externalPriceId: JsonField = JsonMissing.of() + private var fixedPriceQuantity: JsonField = JsonMissing.of() + private var invoiceGroupingKey: JsonField = JsonMissing.of() + private var invoicingCycleConfiguration: + JsonField = + JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var referenceId: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -45545,28 +60571,42 @@ constructor( } fun bulkWithProrationConfig(bulkWithProrationConfig: BulkWithProrationConfig) = - apply { - this.bulkWithProrationConfig = bulkWithProrationConfig - } + bulkWithProrationConfig(JsonField.of(bulkWithProrationConfig)) + + fun bulkWithProrationConfig( + bulkWithProrationConfig: JsonField + ) = apply { this.bulkWithProrationConfig = bulkWithProrationConfig } /** The cadence to bill for this price on. */ - fun cadence(cadence: Cadence) = apply { this.cadence = cadence } + fun cadence(cadence: Cadence) = cadence(JsonField.of(cadence)) + + /** The cadence to bill for this price on. */ + fun cadence(cadence: JsonField) = apply { this.cadence = cadence } /** The id of the item the plan will be associated with. */ - fun itemId(itemId: String) = apply { this.itemId = itemId } + fun itemId(itemId: String) = itemId(JsonField.of(itemId)) - fun modelType(modelType: ModelType) = apply { this.modelType = modelType } + /** The id of the item the plan will be associated with. */ + fun itemId(itemId: JsonField) = apply { this.itemId = itemId } + + fun modelType(modelType: ModelType) = modelType(JsonField.of(modelType)) + + fun modelType(modelType: JsonField) = apply { + this.modelType = modelType + } + + /** The name of the price. */ + fun name(name: String) = name(JsonField.of(name)) /** The name of the price. */ - fun name(name: String) = apply { this.name = name } + fun name(name: JsonField) = apply { this.name = name } /** * The id of the billable metric for the price. Only needed if the price is * usage-based. */ - fun billableMetricId(billableMetricId: String?) = apply { - this.billableMetricId = billableMetricId - } + fun billableMetricId(billableMetricId: String?) = + billableMetricId(JsonField.ofNullable(billableMetricId)) /** * The id of the billable metric for the price. Only needed if the price is @@ -45575,13 +60615,20 @@ constructor( fun billableMetricId(billableMetricId: Optional) = billableMetricId(billableMetricId.orElse(null)) + /** + * The id of the billable metric for the price. Only needed if the price is + * usage-based. + */ + fun billableMetricId(billableMetricId: JsonField) = apply { + this.billableMetricId = billableMetricId + } + /** * If the Price represents a fixed cost, the price will be billed in-advance if * this is true, and in-arrears if this is false. */ - fun billedInAdvance(billedInAdvance: Boolean?) = apply { - this.billedInAdvance = billedInAdvance - } + fun billedInAdvance(billedInAdvance: Boolean?) = + billedInAdvance(JsonField.ofNullable(billedInAdvance)) /** * If the Price represents a fixed cost, the price will be billed in-advance if @@ -45598,13 +60645,21 @@ constructor( fun billedInAdvance(billedInAdvance: Optional) = billedInAdvance(billedInAdvance.orElse(null) as Boolean?) + /** + * If the Price represents a fixed cost, the price will be billed in-advance if + * this is true, and in-arrears if this is false. + */ + fun billedInAdvance(billedInAdvance: JsonField) = apply { + this.billedInAdvance = billedInAdvance + } + /** * For custom cadence: specifies the duration of the billing period in days or * months. */ fun billingCycleConfiguration( billingCycleConfiguration: BillingCycleConfiguration? - ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + ) = billingCycleConfiguration(JsonField.ofNullable(billingCycleConfiguration)) /** * For custom cadence: specifies the duration of the billing period in days or @@ -45614,12 +60669,19 @@ constructor( billingCycleConfiguration: Optional ) = billingCycleConfiguration(billingCycleConfiguration.orElse(null)) + /** + * For custom cadence: specifies the duration of the billing period in days or + * months. + */ + fun billingCycleConfiguration( + billingCycleConfiguration: JsonField + ) = apply { this.billingCycleConfiguration = billingCycleConfiguration } + /** * The per unit conversion rate of the price currency to the invoicing currency. */ - fun conversionRate(conversionRate: Double?) = apply { - this.conversionRate = conversionRate - } + fun conversionRate(conversionRate: Double?) = + conversionRate(JsonField.ofNullable(conversionRate)) /** * The per unit conversion rate of the price currency to the invoicing currency. @@ -45634,11 +60696,18 @@ constructor( fun conversionRate(conversionRate: Optional) = conversionRate(conversionRate.orElse(null) as Double?) + /** + * The per unit conversion rate of the price currency to the invoicing currency. + */ + fun conversionRate(conversionRate: JsonField) = apply { + this.conversionRate = conversionRate + } + /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this * price is billed. */ - fun currency(currency: String?) = apply { this.currency = currency } + fun currency(currency: String?) = currency(JsonField.ofNullable(currency)) /** * An ISO 4217 currency string, or custom pricing unit identifier, in which this @@ -45646,22 +60715,31 @@ constructor( */ fun currency(currency: Optional) = currency(currency.orElse(null)) + /** + * An ISO 4217 currency string, or custom pricing unit identifier, in which this + * price is billed. + */ + fun currency(currency: JsonField) = apply { this.currency = currency } + /** An alias for the price. */ - fun externalPriceId(externalPriceId: String?) = apply { - this.externalPriceId = externalPriceId - } + fun externalPriceId(externalPriceId: String?) = + externalPriceId(JsonField.ofNullable(externalPriceId)) /** An alias for the price. */ fun externalPriceId(externalPriceId: Optional) = externalPriceId(externalPriceId.orElse(null)) + /** An alias for the price. */ + fun externalPriceId(externalPriceId: JsonField) = apply { + this.externalPriceId = externalPriceId + } + /** * If the Price represents a fixed cost, this represents the quantity of units * applied. */ - fun fixedPriceQuantity(fixedPriceQuantity: Double?) = apply { - this.fixedPriceQuantity = fixedPriceQuantity - } + fun fixedPriceQuantity(fixedPriceQuantity: Double?) = + fixedPriceQuantity(JsonField.ofNullable(fixedPriceQuantity)) /** * If the Price represents a fixed cost, this represents the quantity of units @@ -45678,22 +60756,37 @@ constructor( fun fixedPriceQuantity(fixedPriceQuantity: Optional) = fixedPriceQuantity(fixedPriceQuantity.orElse(null) as Double?) - /** The property used to group this price on an invoice */ - fun invoiceGroupingKey(invoiceGroupingKey: String?) = apply { - this.invoiceGroupingKey = invoiceGroupingKey + /** + * If the Price represents a fixed cost, this represents the quantity of units + * applied. + */ + fun fixedPriceQuantity(fixedPriceQuantity: JsonField) = apply { + this.fixedPriceQuantity = fixedPriceQuantity } + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: String?) = + invoiceGroupingKey(JsonField.ofNullable(invoiceGroupingKey)) + /** The property used to group this price on an invoice */ fun invoiceGroupingKey(invoiceGroupingKey: Optional) = invoiceGroupingKey(invoiceGroupingKey.orElse(null)) + /** The property used to group this price on an invoice */ + fun invoiceGroupingKey(invoiceGroupingKey: JsonField) = apply { + this.invoiceGroupingKey = invoiceGroupingKey + } + /** * Within each billing cycle, specifies the cadence at which invoices are * produced. If unspecified, a single invoice is produced per billing cycle. */ fun invoicingCycleConfiguration( invoicingCycleConfiguration: InvoicingCycleConfiguration? - ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + ) = + invoicingCycleConfiguration( + JsonField.ofNullable(invoicingCycleConfiguration) + ) /** * Within each billing cycle, specifies the cadence at which invoices are @@ -45703,12 +60796,20 @@ constructor( invoicingCycleConfiguration: Optional ) = invoicingCycleConfiguration(invoicingCycleConfiguration.orElse(null)) + /** + * Within each billing cycle, specifies the cadence at which invoices are + * produced. If unspecified, a single invoice is produced per billing cycle. + */ + fun invoicingCycleConfiguration( + invoicingCycleConfiguration: JsonField + ) = apply { this.invoicingCycleConfiguration = invoicingCycleConfiguration } + /** * User-specified key/value pairs for the resource. Individual keys can be * removed by setting the value to `null`, and the entire metadata mapping can * be cleared by setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be @@ -45717,11 +60818,19 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be + * removed by setting the value to `null`, and the entire metadata mapping can + * be cleared by setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * A transient ID that can be used to reference this price when adding * adjustments in the same API call. */ - fun referenceId(referenceId: String?) = apply { this.referenceId = referenceId } + fun referenceId(referenceId: String?) = + referenceId(JsonField.ofNullable(referenceId)) /** * A transient ID that can be used to reference this price when adding @@ -45730,6 +60839,14 @@ constructor( fun referenceId(referenceId: Optional) = referenceId(referenceId.orElse(null)) + /** + * A transient ID that can be used to reference this price when adding + * adjustments in the same API call. + */ + fun referenceId(referenceId: JsonField) = apply { + this.referenceId = referenceId + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -45788,6 +60905,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BulkWithProrationConfig = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -45993,22 +61118,46 @@ constructor( class BillingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): BillingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -46018,8 +61167,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -46033,10 +61182,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -46157,22 +61313,46 @@ constructor( class InvoicingCycleConfiguration @JsonCreator private constructor( - @JsonProperty("duration") private val duration: Long, - @JsonProperty("duration_unit") private val durationUnit: DurationUnit, + @JsonProperty("duration") + @ExcludeMissing + private val duration: JsonField = JsonMissing.of(), + @JsonProperty("duration_unit") + @ExcludeMissing + private val durationUnit: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** The duration of the billing period. */ - @JsonProperty("duration") fun duration(): Long = duration + fun duration(): Long = duration.getRequired("duration") + + /** The unit of billing period duration. */ + fun durationUnit(): DurationUnit = durationUnit.getRequired("duration_unit") + + /** The duration of the billing period. */ + @JsonProperty("duration") + @ExcludeMissing + fun _duration(): JsonField = duration /** The unit of billing period duration. */ - @JsonProperty("duration_unit") fun durationUnit(): DurationUnit = durationUnit + @JsonProperty("duration_unit") + @ExcludeMissing + fun _durationUnit(): JsonField = durationUnit @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): InvoicingCycleConfiguration = apply { + if (!validated) { + duration() + durationUnit() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -46182,8 +61362,8 @@ constructor( class Builder { - private var duration: Long? = null - private var durationUnit: DurationUnit? = null + private var duration: JsonField? = null + private var durationUnit: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @@ -46198,10 +61378,17 @@ constructor( } /** The duration of the billing period. */ - fun duration(duration: Long) = apply { this.duration = duration } + fun duration(duration: Long) = duration(JsonField.of(duration)) + + /** The duration of the billing period. */ + fun duration(duration: JsonField) = apply { this.duration = duration } + + /** The unit of billing period duration. */ + fun durationUnit(durationUnit: DurationUnit) = + durationUnit(JsonField.of(durationUnit)) /** The unit of billing period duration. */ - fun durationUnit(durationUnit: DurationUnit) = apply { + fun durationUnit(durationUnit: JsonField) = apply { this.durationUnit = durationUnit } @@ -46331,6 +61518,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt index b6fb1c25..25267042 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionSchedulePlanChangeResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -454,7 +474,10 @@ private constructor( ) = apply { id = subscriptionSchedulePlanChangeResponse.id activePlanPhaseOrder = subscriptionSchedulePlanChangeResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionSchedulePlanChangeResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionSchedulePlanChangeResponse.adjustmentIntervals.map { + it.toMutableList() + } autoCollection = subscriptionSchedulePlanChangeResponse.autoCollection billingCycleAnchorConfiguration = subscriptionSchedulePlanChangeResponse.billingCycleAnchorConfiguration @@ -466,17 +489,23 @@ private constructor( subscriptionSchedulePlanChangeResponse.currentBillingPeriodStartDate customer = subscriptionSchedulePlanChangeResponse.customer defaultInvoiceMemo = subscriptionSchedulePlanChangeResponse.defaultInvoiceMemo - discountIntervals = subscriptionSchedulePlanChangeResponse.discountIntervals + discountIntervals = + subscriptionSchedulePlanChangeResponse.discountIntervals.map { it.toMutableList() } endDate = subscriptionSchedulePlanChangeResponse.endDate fixedFeeQuantitySchedule = - subscriptionSchedulePlanChangeResponse.fixedFeeQuantitySchedule + subscriptionSchedulePlanChangeResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionSchedulePlanChangeResponse.invoicingThreshold - maximumIntervals = subscriptionSchedulePlanChangeResponse.maximumIntervals + maximumIntervals = + subscriptionSchedulePlanChangeResponse.maximumIntervals.map { it.toMutableList() } metadata = subscriptionSchedulePlanChangeResponse.metadata - minimumIntervals = subscriptionSchedulePlanChangeResponse.minimumIntervals + minimumIntervals = + subscriptionSchedulePlanChangeResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionSchedulePlanChangeResponse.netTerms plan = subscriptionSchedulePlanChangeResponse.plan - priceIntervals = subscriptionSchedulePlanChangeResponse.priceIntervals + priceIntervals = + subscriptionSchedulePlanChangeResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionSchedulePlanChangeResponse.redeemedCoupon startDate = subscriptionSchedulePlanChangeResponse.startDate status = subscriptionSchedulePlanChangeResponse.status @@ -489,9 +518,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -504,15 +542,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -558,8 +627,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -576,8 +653,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -632,8 +717,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -649,11 +741,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } } + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } + } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -663,10 +772,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -678,7 +806,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -701,7 +843,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -740,11 +896,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -785,31 +958,55 @@ private constructor( fun build(): SubscriptionSchedulePlanChangeResponse = SubscriptionSchedulePlanChangeResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -850,20 +1047,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -891,18 +1094,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -918,6 +1122,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -925,11 +1144,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -963,11 +1200,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1270,11 +1510,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1282,12 +1522,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1295,15 +1535,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1333,13 +1573,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1347,7 +1587,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1387,7 +1628,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1405,9 +1660,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1415,7 +1679,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1444,13 +1711,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1582,16 +1860,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1599,7 +1877,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1607,15 +1885,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1645,13 +1923,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1659,7 +1937,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1685,7 +1966,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1718,9 +2013,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1728,7 +2032,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1757,13 +2064,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1894,16 +2212,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1911,21 +2229,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1955,20 +2275,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1994,7 +2315,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2012,9 +2347,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2022,7 +2366,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2066,13 +2413,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2209,16 +2567,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2226,24 +2584,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2274,21 +2634,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2314,7 +2675,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2353,9 +2728,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2363,7 +2747,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2392,14 +2779,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2530,16 +2928,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2547,21 +2945,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2591,20 +2991,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2629,7 +3030,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2662,9 +3077,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2672,7 +3096,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2701,13 +3128,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2840,19 +3278,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2878,7 +3316,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2913,7 +3351,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2925,7 +3376,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2954,7 +3418,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3206,25 +3670,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3253,19 +3725,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3288,7 +3762,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3298,9 +3786,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3309,7 +3812,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3346,12 +3852,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3474,25 +3988,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3521,18 +4041,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3547,7 +4071,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3557,9 +4095,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3568,7 +4121,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3618,12 +4174,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3749,26 +4313,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3797,18 +4369,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3822,7 +4396,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3832,9 +4420,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3843,7 +4446,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3895,12 +4501,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4004,13 +4618,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4037,10 +4655,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4052,7 +4670,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4091,10 +4711,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4164,24 +4784,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4209,17 +4835,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4232,7 +4859,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4242,11 +4883,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4294,11 +4953,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4448,24 +5113,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4493,17 +5164,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4516,7 +5188,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4526,11 +5212,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4578,11 +5282,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4917,10 +5627,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4929,7 +5641,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4938,13 +5650,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4952,7 +5667,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5182,13 +5898,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5219,15 +5937,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5237,7 +5956,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5261,8 +5981,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5278,8 +6006,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5294,7 +6031,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5307,8 +6050,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5316,7 +6067,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5778,6 +6551,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5813,14 +6651,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5848,11 +6695,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5878,9 +6727,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5931,9 +6780,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5998,11 +6849,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6028,9 +6883,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6045,7 +6900,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6076,9 +6933,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6178,7 +7035,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6202,7 +7061,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6211,7 +7070,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6234,7 +7095,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt index eb5a43ca..e0c387cb 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -17,6 +19,7 @@ import java.time.LocalDate import java.util.Objects import java.util.Optional +/** Manually trigger a phase, effective the given date (or the current time, if not specified). */ class SubscriptionTriggerPhaseParams constructor( private val subscriptionId: String, @@ -33,12 +36,18 @@ constructor( */ fun effectiveDate(): Optional = body.effectiveDate() + /** + * The date on which the phase change should take effect. If not provided, defaults to today in + * the customer's timezone. + */ + fun _effectiveDate(): JsonField = body._effectiveDate() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): SubscriptionTriggerPhaseBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -56,22 +65,41 @@ constructor( class SubscriptionTriggerPhaseBody @JsonCreator internal constructor( - @JsonProperty("effective_date") private val effectiveDate: LocalDate?, + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * The date on which the phase change should take effect. If not provided, defaults to today + * in the customer's timezone. + */ + fun effectiveDate(): Optional = + Optional.ofNullable(effectiveDate.getNullable("effective_date")) + /** * The date on which the phase change should take effect. If not provided, defaults to today * in the customer's timezone. */ @JsonProperty("effective_date") - fun effectiveDate(): Optional = Optional.ofNullable(effectiveDate) + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionTriggerPhaseBody = apply { + if (!validated) { + effectiveDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -81,7 +109,7 @@ constructor( class Builder { - private var effectiveDate: LocalDate? = null + private var effectiveDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -95,9 +123,8 @@ constructor( * The date on which the phase change should take effect. If not provided, defaults to * today in the customer's timezone. */ - fun effectiveDate(effectiveDate: LocalDate?) = apply { - this.effectiveDate = effectiveDate - } + fun effectiveDate(effectiveDate: LocalDate?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) /** * The date on which the phase change should take effect. If not provided, defaults to @@ -106,6 +133,14 @@ constructor( fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.orElse(null)) + /** + * The date on which the phase change should take effect. If not provided, defaults to + * today in the customer's timezone. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -186,6 +221,33 @@ constructor( fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.orElse(null)) + /** + * The date on which the phase change should take effect. If not provided, defaults to today + * in the customer's timezone. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -284,25 +346,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionTriggerPhaseParams = SubscriptionTriggerPhaseParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt index 7d9d66b5..36b884f4 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionTriggerPhaseResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -453,7 +473,8 @@ private constructor( apply { id = subscriptionTriggerPhaseResponse.id activePlanPhaseOrder = subscriptionTriggerPhaseResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionTriggerPhaseResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionTriggerPhaseResponse.adjustmentIntervals.map { it.toMutableList() } autoCollection = subscriptionTriggerPhaseResponse.autoCollection billingCycleAnchorConfiguration = subscriptionTriggerPhaseResponse.billingCycleAnchorConfiguration @@ -465,16 +486,23 @@ private constructor( subscriptionTriggerPhaseResponse.currentBillingPeriodStartDate customer = subscriptionTriggerPhaseResponse.customer defaultInvoiceMemo = subscriptionTriggerPhaseResponse.defaultInvoiceMemo - discountIntervals = subscriptionTriggerPhaseResponse.discountIntervals + discountIntervals = + subscriptionTriggerPhaseResponse.discountIntervals.map { it.toMutableList() } endDate = subscriptionTriggerPhaseResponse.endDate - fixedFeeQuantitySchedule = subscriptionTriggerPhaseResponse.fixedFeeQuantitySchedule + fixedFeeQuantitySchedule = + subscriptionTriggerPhaseResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionTriggerPhaseResponse.invoicingThreshold - maximumIntervals = subscriptionTriggerPhaseResponse.maximumIntervals + maximumIntervals = + subscriptionTriggerPhaseResponse.maximumIntervals.map { it.toMutableList() } metadata = subscriptionTriggerPhaseResponse.metadata - minimumIntervals = subscriptionTriggerPhaseResponse.minimumIntervals + minimumIntervals = + subscriptionTriggerPhaseResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionTriggerPhaseResponse.netTerms plan = subscriptionTriggerPhaseResponse.plan - priceIntervals = subscriptionTriggerPhaseResponse.priceIntervals + priceIntervals = + subscriptionTriggerPhaseResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionTriggerPhaseResponse.redeemedCoupon startDate = subscriptionTriggerPhaseResponse.startDate status = subscriptionTriggerPhaseResponse.status @@ -487,9 +515,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -502,15 +539,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -556,8 +624,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -574,8 +650,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -630,8 +714,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -647,11 +738,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -661,10 +769,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -676,7 +803,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -699,7 +840,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -738,11 +893,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -783,31 +955,55 @@ private constructor( fun build(): SubscriptionTriggerPhaseResponse = SubscriptionTriggerPhaseResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -848,20 +1044,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -889,18 +1091,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -916,6 +1119,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -923,11 +1141,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -961,11 +1197,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1268,11 +1507,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1280,12 +1519,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1293,15 +1532,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1331,13 +1570,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1345,7 +1584,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1385,7 +1625,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1403,9 +1657,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1413,7 +1676,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1442,13 +1708,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1580,16 +1857,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1597,7 +1874,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1605,15 +1882,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1643,13 +1920,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1657,7 +1934,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1683,7 +1963,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1716,9 +2010,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1726,7 +2029,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1755,13 +2061,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1892,16 +2209,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1909,21 +2226,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1953,20 +2272,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1992,7 +2312,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2010,9 +2344,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2020,7 +2363,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2064,13 +2410,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2207,16 +2564,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2224,24 +2581,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2272,21 +2631,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2312,7 +2672,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2351,9 +2725,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2361,7 +2744,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2390,14 +2776,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2528,16 +2925,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2545,21 +2942,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2589,20 +2988,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2627,7 +3027,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2660,9 +3074,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2670,7 +3093,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2699,13 +3125,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2838,19 +3275,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2876,7 +3313,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2911,7 +3348,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2923,7 +3373,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2952,7 +3415,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3204,25 +3667,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3251,19 +3722,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3286,7 +3759,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3296,9 +3783,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3307,7 +3809,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3344,12 +3849,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3472,25 +3985,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3519,18 +4038,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3545,7 +4068,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3555,9 +4092,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3566,7 +4118,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3616,12 +4171,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3747,26 +4310,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3795,18 +4366,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3820,7 +4393,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3830,9 +4417,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3841,7 +4443,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3893,12 +4498,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4002,13 +4615,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4035,10 +4652,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4050,7 +4667,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4089,10 +4708,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4162,24 +4781,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4207,17 +4832,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4230,7 +4856,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4240,11 +4880,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4292,11 +4950,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4446,24 +5110,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4491,17 +5161,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4514,7 +5185,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4524,11 +5209,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4576,11 +5279,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4915,10 +5624,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4927,7 +5638,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4936,13 +5647,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4950,7 +5664,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5180,13 +5895,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5217,15 +5934,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5235,7 +5953,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5259,8 +5978,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5276,8 +6003,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5292,7 +6028,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5305,8 +6047,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5314,7 +6064,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5776,6 +6548,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5811,14 +6648,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5846,11 +6692,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5876,9 +6724,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5929,9 +6777,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5996,11 +6846,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6026,9 +6880,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6043,7 +6897,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6074,9 +6930,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6176,7 +7032,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6200,7 +7058,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6209,7 +7067,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6232,7 +7092,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt index f9b83ee5..1d53f0d0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationParams.kt @@ -10,6 +10,13 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint can be used to unschedule any pending cancellations for a subscription. + * + * To be eligible, the subscription must currently be active and have a future cancellation. This + * operation will turn on auto-renew, ensuring that the subscription does not end at the currently + * scheduled cancellation time. + */ class SubscriptionUnscheduleCancellationParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt index 005309db..6f56f3ea 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleCancellationResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -454,7 +474,10 @@ private constructor( ) = apply { id = subscriptionUnscheduleCancellationResponse.id activePlanPhaseOrder = subscriptionUnscheduleCancellationResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionUnscheduleCancellationResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionUnscheduleCancellationResponse.adjustmentIntervals.map { + it.toMutableList() + } autoCollection = subscriptionUnscheduleCancellationResponse.autoCollection billingCycleAnchorConfiguration = subscriptionUnscheduleCancellationResponse.billingCycleAnchorConfiguration @@ -466,17 +489,29 @@ private constructor( subscriptionUnscheduleCancellationResponse.currentBillingPeriodStartDate customer = subscriptionUnscheduleCancellationResponse.customer defaultInvoiceMemo = subscriptionUnscheduleCancellationResponse.defaultInvoiceMemo - discountIntervals = subscriptionUnscheduleCancellationResponse.discountIntervals + discountIntervals = + subscriptionUnscheduleCancellationResponse.discountIntervals.map { + it.toMutableList() + } endDate = subscriptionUnscheduleCancellationResponse.endDate fixedFeeQuantitySchedule = - subscriptionUnscheduleCancellationResponse.fixedFeeQuantitySchedule + subscriptionUnscheduleCancellationResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionUnscheduleCancellationResponse.invoicingThreshold - maximumIntervals = subscriptionUnscheduleCancellationResponse.maximumIntervals + maximumIntervals = + subscriptionUnscheduleCancellationResponse.maximumIntervals.map { + it.toMutableList() + } metadata = subscriptionUnscheduleCancellationResponse.metadata - minimumIntervals = subscriptionUnscheduleCancellationResponse.minimumIntervals + minimumIntervals = + subscriptionUnscheduleCancellationResponse.minimumIntervals.map { + it.toMutableList() + } netTerms = subscriptionUnscheduleCancellationResponse.netTerms plan = subscriptionUnscheduleCancellationResponse.plan - priceIntervals = subscriptionUnscheduleCancellationResponse.priceIntervals + priceIntervals = + subscriptionUnscheduleCancellationResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionUnscheduleCancellationResponse.redeemedCoupon startDate = subscriptionUnscheduleCancellationResponse.startDate status = subscriptionUnscheduleCancellationResponse.status @@ -489,9 +524,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -504,7 +548,21 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } } /** @@ -512,7 +570,24 @@ private constructor( * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -558,8 +633,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -576,8 +659,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -632,8 +723,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -649,11 +747,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -663,10 +778,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -678,7 +812,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -701,7 +849,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -740,11 +902,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -785,31 +964,55 @@ private constructor( fun build(): SubscriptionUnscheduleCancellationResponse = SubscriptionUnscheduleCancellationResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -850,20 +1053,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -891,18 +1100,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -918,6 +1128,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -925,11 +1150,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -963,11 +1206,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1270,11 +1516,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1282,12 +1528,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1295,15 +1541,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1333,13 +1579,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1347,7 +1593,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1387,7 +1634,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1405,9 +1666,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1415,7 +1685,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1444,13 +1717,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1582,16 +1866,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1599,7 +1883,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1607,15 +1891,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1645,13 +1929,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1659,7 +1943,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1685,7 +1972,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1718,9 +2019,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1728,7 +2038,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1757,13 +2070,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1894,16 +2218,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1911,21 +2235,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1955,20 +2281,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1994,7 +2321,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2012,9 +2353,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2022,7 +2372,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2066,13 +2419,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2209,16 +2573,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2226,24 +2590,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2274,21 +2640,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2314,7 +2681,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2353,9 +2734,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2363,7 +2753,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2392,14 +2785,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2530,16 +2934,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2547,21 +2951,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2591,20 +2997,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2629,7 +3036,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2662,9 +3083,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2672,7 +3102,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2701,13 +3134,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2840,19 +3284,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2878,7 +3322,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2913,7 +3357,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2925,7 +3382,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2954,7 +3424,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3206,25 +3676,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3253,19 +3731,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3288,7 +3768,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3298,9 +3792,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3309,7 +3818,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3346,12 +3858,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3474,25 +3994,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3521,18 +4047,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3547,7 +4077,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3557,9 +4101,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3568,7 +4127,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3618,12 +4180,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3749,26 +4319,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3797,18 +4375,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3822,7 +4402,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3832,9 +4426,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3843,7 +4452,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3895,12 +4507,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4004,13 +4624,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4037,10 +4661,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4052,7 +4676,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4091,10 +4717,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4164,24 +4790,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4209,17 +4841,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4232,7 +4865,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4242,11 +4889,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4294,11 +4959,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4448,24 +5119,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4493,17 +5170,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4516,7 +5194,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4526,11 +5218,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4578,11 +5288,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4917,10 +5633,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4929,7 +5647,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4938,13 +5656,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4952,7 +5673,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5182,13 +5904,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5219,15 +5943,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5237,7 +5962,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5261,8 +5987,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5278,8 +6012,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5294,7 +6037,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5307,8 +6056,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5316,7 +6073,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5778,6 +6557,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5813,14 +6657,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5848,11 +6701,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5878,9 +6733,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5931,9 +6786,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5998,11 +6855,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6028,9 +6889,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6045,7 +6906,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6076,9 +6939,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6178,7 +7041,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6202,7 +7067,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6211,7 +7076,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6234,7 +7101,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt index 9a5e8b0a..5731bee7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -15,6 +17,12 @@ import com.withorb.api.core.immutableEmptyMap import com.withorb.api.core.toImmutable import java.util.Objects +/** + * This endpoint can be used to clear scheduled updates to the quantity for a fixed fee. + * + * If there are no updates scheduled, a request validation error will be returned with a 400 status + * code. + */ class SubscriptionUnscheduleFixedFeeQuantityUpdatesParams constructor( private val subscriptionId: String, @@ -28,12 +36,15 @@ constructor( /** Price for which the updates should be cleared. Must be a fixed fee. */ fun priceId(): String = body.priceId() + /** Price for which the updates should be cleared. Must be a fixed fee. */ + fun _priceId(): JsonField = body._priceId() + + fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders fun _additionalQueryParams(): QueryParams = additionalQueryParams - fun _additionalBodyProperties(): Map = body._additionalProperties() - @JvmSynthetic internal fun getBody(): SubscriptionUnscheduleFixedFeeQuantityUpdatesBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -51,18 +62,32 @@ constructor( class SubscriptionUnscheduleFixedFeeQuantityUpdatesBody @JsonCreator internal constructor( - @JsonProperty("price_id") private val priceId: String, + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Price for which the updates should be cleared. Must be a fixed fee. */ - @JsonProperty("price_id") fun priceId(): String = priceId + fun priceId(): String = priceId.getRequired("price_id") + + /** Price for which the updates should be cleared. Must be a fixed fee. */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionUnscheduleFixedFeeQuantityUpdatesBody = apply { + if (!validated) { + priceId() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -72,7 +97,7 @@ constructor( class Builder { - private var priceId: String? = null + private var priceId: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -87,7 +112,10 @@ constructor( } /** Price for which the updates should be cleared. Must be a fixed fee. */ - fun priceId(priceId: String) = apply { this.priceId = priceId } + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** Price for which the updates should be cleared. Must be a fixed fee. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -168,6 +196,28 @@ constructor( /** Price for which the updates should be cleared. Must be a fixed fee. */ fun priceId(priceId: String) = apply { body.priceId(priceId) } + /** Price for which the updates should be cleared. Must be a fixed fee. */ + fun priceId(priceId: JsonField) = apply { body.priceId(priceId) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -266,25 +316,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionUnscheduleFixedFeeQuantityUpdatesParams = SubscriptionUnscheduleFixedFeeQuantityUpdatesParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt index f8edcee5..0b982576 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -457,7 +477,9 @@ private constructor( activePlanPhaseOrder = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.activePlanPhaseOrder adjustmentIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.adjustmentIntervals + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.adjustmentIntervals.map { + it.toMutableList() + } autoCollection = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.autoCollection billingCycleAnchorConfiguration = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse @@ -472,20 +494,31 @@ private constructor( defaultInvoiceMemo = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.defaultInvoiceMemo discountIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.discountIntervals + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.discountIntervals.map { + it.toMutableList() + } endDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.endDate fixedFeeQuantitySchedule = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.fixedFeeQuantitySchedule + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.invoicingThreshold maximumIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.maximumIntervals + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.maximumIntervals.map { + it.toMutableList() + } metadata = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.metadata minimumIntervals = - subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.minimumIntervals + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.minimumIntervals.map { + it.toMutableList() + } netTerms = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.netTerms plan = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.plan - priceIntervals = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals + priceIntervals = + subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.priceIntervals.map { + it.toMutableList() + } redeemedCoupon = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.redeemedCoupon startDate = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.startDate status = subscriptionUnscheduleFixedFeeQuantityUpdatesResponse.status @@ -499,9 +532,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -514,7 +556,21 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } } /** @@ -522,7 +578,24 @@ private constructor( * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -568,8 +641,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -586,8 +667,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -642,8 +731,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -659,11 +755,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -673,10 +786,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -688,7 +820,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -711,7 +857,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -750,11 +910,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -795,31 +972,55 @@ private constructor( fun build(): SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse = SubscriptionUnscheduleFixedFeeQuantityUpdatesResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -860,20 +1061,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -901,18 +1108,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -928,6 +1136,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -935,11 +1158,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -973,11 +1214,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1280,11 +1524,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1292,12 +1536,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1305,15 +1549,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1343,13 +1587,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1357,7 +1601,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1397,7 +1642,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1415,9 +1674,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1425,7 +1693,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1454,13 +1725,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1592,16 +1874,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1609,7 +1891,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1617,15 +1899,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1655,13 +1937,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1669,7 +1951,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1695,7 +1980,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1728,9 +2027,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1738,7 +2046,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1767,13 +2078,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1904,16 +2226,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1921,21 +2243,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1965,20 +2289,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -2004,7 +2329,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2022,9 +2361,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2032,7 +2380,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2076,13 +2427,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2219,16 +2581,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2236,24 +2598,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2284,21 +2648,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2324,7 +2689,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2363,9 +2742,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2373,7 +2761,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2402,14 +2793,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2540,16 +2942,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2557,21 +2959,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2601,20 +3005,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2639,7 +3044,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2672,9 +3091,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2682,7 +3110,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2711,13 +3142,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2850,19 +3292,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2888,7 +3330,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2923,7 +3365,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2935,7 +3390,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2964,7 +3432,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3216,25 +3684,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3263,19 +3739,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3298,7 +3776,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3308,9 +3800,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3319,7 +3826,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3356,12 +3866,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3484,25 +4002,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3531,18 +4055,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3557,7 +4085,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3567,9 +4109,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3578,7 +4135,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3628,12 +4188,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3759,26 +4327,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3807,18 +4383,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3832,7 +4410,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3842,9 +4434,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3853,7 +4460,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3905,12 +4515,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4014,13 +4632,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4047,10 +4669,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4062,7 +4684,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4101,10 +4725,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4174,24 +4798,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4219,17 +4849,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4242,7 +4873,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4252,11 +4897,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the maximum interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4304,11 +4967,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4458,24 +5127,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4503,17 +5178,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4526,7 +5202,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4536,11 +5226,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the minimum interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4588,11 +5296,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4927,10 +5641,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4939,7 +5655,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4948,13 +5664,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4962,7 +5681,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5192,13 +5912,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5229,15 +5951,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5247,7 +5970,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5271,8 +5995,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5288,8 +6020,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5304,7 +6045,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5317,8 +6064,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5326,7 +6081,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5788,6 +6565,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5823,14 +6665,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5858,11 +6709,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5888,9 +6741,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5941,9 +6794,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6008,11 +6863,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6038,9 +6897,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6055,7 +6914,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6086,9 +6947,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6188,7 +7049,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6212,7 +7075,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6221,7 +7084,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6244,7 +7109,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt index 7de0a3cc..0a042357 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesParams.kt @@ -10,6 +10,7 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** This endpoint can be used to unschedule any pending plan changes on an existing subscription. */ class SubscriptionUnschedulePendingPlanChangesParams constructor( private val subscriptionId: String, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt index ce81da9f..680a0b26 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUnschedulePendingPlanChangesResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -457,7 +477,9 @@ private constructor( activePlanPhaseOrder = subscriptionUnschedulePendingPlanChangesResponse.activePlanPhaseOrder adjustmentIntervals = - subscriptionUnschedulePendingPlanChangesResponse.adjustmentIntervals + subscriptionUnschedulePendingPlanChangesResponse.adjustmentIntervals.map { + it.toMutableList() + } autoCollection = subscriptionUnschedulePendingPlanChangesResponse.autoCollection billingCycleAnchorConfiguration = subscriptionUnschedulePendingPlanChangesResponse.billingCycleAnchorConfiguration @@ -469,17 +491,31 @@ private constructor( subscriptionUnschedulePendingPlanChangesResponse.currentBillingPeriodStartDate customer = subscriptionUnschedulePendingPlanChangesResponse.customer defaultInvoiceMemo = subscriptionUnschedulePendingPlanChangesResponse.defaultInvoiceMemo - discountIntervals = subscriptionUnschedulePendingPlanChangesResponse.discountIntervals + discountIntervals = + subscriptionUnschedulePendingPlanChangesResponse.discountIntervals.map { + it.toMutableList() + } endDate = subscriptionUnschedulePendingPlanChangesResponse.endDate fixedFeeQuantitySchedule = - subscriptionUnschedulePendingPlanChangesResponse.fixedFeeQuantitySchedule + subscriptionUnschedulePendingPlanChangesResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionUnschedulePendingPlanChangesResponse.invoicingThreshold - maximumIntervals = subscriptionUnschedulePendingPlanChangesResponse.maximumIntervals + maximumIntervals = + subscriptionUnschedulePendingPlanChangesResponse.maximumIntervals.map { + it.toMutableList() + } metadata = subscriptionUnschedulePendingPlanChangesResponse.metadata - minimumIntervals = subscriptionUnschedulePendingPlanChangesResponse.minimumIntervals + minimumIntervals = + subscriptionUnschedulePendingPlanChangesResponse.minimumIntervals.map { + it.toMutableList() + } netTerms = subscriptionUnschedulePendingPlanChangesResponse.netTerms plan = subscriptionUnschedulePendingPlanChangesResponse.plan - priceIntervals = subscriptionUnschedulePendingPlanChangesResponse.priceIntervals + priceIntervals = + subscriptionUnschedulePendingPlanChangesResponse.priceIntervals.map { + it.toMutableList() + } redeemedCoupon = subscriptionUnschedulePendingPlanChangesResponse.redeemedCoupon startDate = subscriptionUnschedulePendingPlanChangesResponse.startDate status = subscriptionUnschedulePendingPlanChangesResponse.status @@ -492,9 +528,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -507,7 +552,21 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } } /** @@ -515,7 +574,24 @@ private constructor( * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -561,8 +637,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -579,8 +663,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -635,8 +727,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -652,11 +751,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } } + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } + } + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -666,10 +782,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -681,7 +816,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -704,7 +853,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -743,11 +906,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -788,31 +968,55 @@ private constructor( fun build(): SubscriptionUnschedulePendingPlanChangesResponse = SubscriptionUnschedulePendingPlanChangesResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -853,20 +1057,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -894,18 +1104,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -921,6 +1132,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -928,11 +1154,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -966,11 +1210,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1273,11 +1520,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1285,12 +1532,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1298,15 +1545,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1336,13 +1583,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1350,7 +1597,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1390,7 +1638,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1408,9 +1670,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1418,7 +1689,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1447,13 +1721,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1585,16 +1870,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1602,7 +1887,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1610,15 +1895,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1648,13 +1933,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1662,7 +1947,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1688,7 +1976,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1721,9 +2023,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1731,7 +2042,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1760,13 +2074,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1897,16 +2222,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1914,21 +2239,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1958,20 +2285,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1997,7 +2325,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2015,9 +2357,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2025,7 +2376,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2069,13 +2423,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2212,16 +2577,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2229,24 +2594,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2277,21 +2644,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2317,7 +2685,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2356,9 +2738,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2366,7 +2757,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2395,14 +2789,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2533,16 +2938,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2550,21 +2955,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2594,20 +3001,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2632,7 +3040,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2665,9 +3087,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2675,7 +3106,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2704,13 +3138,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2843,19 +3288,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2881,7 +3326,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2916,7 +3361,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2928,7 +3386,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2957,7 +3428,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3209,25 +3680,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3256,19 +3735,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3291,7 +3772,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3301,9 +3796,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3312,7 +3822,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3349,12 +3862,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3477,25 +3998,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3524,18 +4051,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3550,7 +4081,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3560,9 +4105,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3571,7 +4131,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3621,12 +4184,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3752,26 +4323,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3800,18 +4379,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3825,7 +4406,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3835,9 +4430,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3846,7 +4456,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3898,12 +4511,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4007,13 +4628,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4040,10 +4665,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4055,7 +4680,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4094,10 +4721,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4167,24 +4794,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4212,17 +4845,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4235,7 +4869,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4245,11 +4893,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the maximum interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4297,11 +4963,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4451,24 +5123,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4496,17 +5174,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4519,7 +5198,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4529,11 +5222,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the minimum interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4581,11 +5292,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4920,10 +5637,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4932,7 +5651,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4941,13 +5660,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4955,7 +5677,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5185,13 +5908,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5222,15 +5947,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5240,7 +5966,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5264,8 +5991,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5281,8 +6016,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5297,7 +6041,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5310,8 +6060,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5319,7 +6077,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5781,6 +6561,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5816,14 +6661,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5851,11 +6705,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5881,9 +6737,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5934,9 +6790,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6001,11 +6859,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6031,9 +6893,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6048,7 +6910,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6079,9 +6943,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6181,7 +7045,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6205,7 +7071,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6214,7 +7080,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6237,7 +7105,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt index 46513293..72967d56 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityParams.kt @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -20,6 +21,20 @@ import java.time.LocalDate import java.util.Objects import java.util.Optional +/** + * This endpoint can be used to update the quantity for a fixed fee. + * + * To be eligible, the subscription must currently be active and the price specified must be a fixed + * fee (not usage-based). This operation will immediately update the quantity for the fee, or if a + * `effective_date` is passed in, will update the quantity on the requested date at midnight in the + * customer's timezone. + * + * In order to change the fixed fee quantity as of the next draft invoice for this subscription, + * pass `change_option=upcoming_invoice` without an `effective_date` specified. + * + * If the fee is an in-advance fixed fee, it will also issue an immediate invoice for the difference + * for the remainder of the billing period. + */ class SubscriptionUpdateFixedFeeQuantityParams constructor( private val subscriptionId: String, @@ -49,12 +64,31 @@ constructor( */ fun effectiveDate(): Optional = body.effectiveDate() - fun _additionalHeaders(): Headers = additionalHeaders + /** Price for which the quantity should be updated. Must be a fixed fee. */ + fun _priceId(): JsonField = body._priceId() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + fun _quantity(): JsonField = body._quantity() + + /** + * Determines when the change takes effect. Note that if `effective_date` is specified, this + * defaults to `effective_date`. Otherwise, this defaults to `immediate` unless it's explicitly + * set to `upcoming_invoice. + */ + fun _changeOption(): JsonField = body._changeOption() + + /** + * The date that the quantity change should take effect, localized to the customer's timezone. + * Ifthis parameter is not passed in, the quantity change is effective according to + * `change_option`. + */ + fun _effectiveDate(): JsonField = body._effectiveDate() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionUpdateFixedFeeQuantityBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -72,18 +106,47 @@ constructor( class SubscriptionUpdateFixedFeeQuantityBody @JsonCreator internal constructor( - @JsonProperty("price_id") private val priceId: String, - @JsonProperty("quantity") private val quantity: Double, - @JsonProperty("change_option") private val changeOption: ChangeOption?, - @JsonProperty("effective_date") private val effectiveDate: LocalDate?, + @JsonProperty("price_id") + @ExcludeMissing + private val priceId: JsonField = JsonMissing.of(), + @JsonProperty("quantity") + @ExcludeMissing + private val quantity: JsonField = JsonMissing.of(), + @JsonProperty("change_option") + @ExcludeMissing + private val changeOption: JsonField = JsonMissing.of(), + @JsonProperty("effective_date") + @ExcludeMissing + private val effectiveDate: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { /** Price for which the quantity should be updated. Must be a fixed fee. */ - @JsonProperty("price_id") fun priceId(): String = priceId + fun priceId(): String = priceId.getRequired("price_id") + + fun quantity(): Double = quantity.getRequired("quantity") + + /** + * Determines when the change takes effect. Note that if `effective_date` is specified, this + * defaults to `effective_date`. Otherwise, this defaults to `immediate` unless it's + * explicitly set to `upcoming_invoice. + */ + fun changeOption(): Optional = + Optional.ofNullable(changeOption.getNullable("change_option")) + + /** + * The date that the quantity change should take effect, localized to the customer's + * timezone. Ifthis parameter is not passed in, the quantity change is effective according + * to `change_option`. + */ + fun effectiveDate(): Optional = + Optional.ofNullable(effectiveDate.getNullable("effective_date")) + + /** Price for which the quantity should be updated. Must be a fixed fee. */ + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") fun quantity(): Double = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity /** * Determines when the change takes effect. Note that if `effective_date` is specified, this @@ -91,7 +154,8 @@ constructor( * explicitly set to `upcoming_invoice. */ @JsonProperty("change_option") - fun changeOption(): Optional = Optional.ofNullable(changeOption) + @ExcludeMissing + fun _changeOption(): JsonField = changeOption /** * The date that the quantity change should take effect, localized to the customer's @@ -99,12 +163,25 @@ constructor( * to `change_option`. */ @JsonProperty("effective_date") - fun effectiveDate(): Optional = Optional.ofNullable(effectiveDate) + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionUpdateFixedFeeQuantityBody = apply { + if (!validated) { + priceId() + quantity() + changeOption() + effectiveDate() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -114,10 +191,10 @@ constructor( class Builder { - private var priceId: String? = null - private var quantity: Double? = null - private var changeOption: ChangeOption? = null - private var effectiveDate: LocalDate? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var changeOption: JsonField = JsonMissing.of() + private var effectiveDate: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -133,35 +210,38 @@ constructor( } /** Price for which the quantity should be updated. Must be a fixed fee. */ - fun priceId(priceId: String) = apply { this.priceId = priceId } + fun priceId(priceId: String) = priceId(JsonField.of(priceId)) + + /** Price for which the quantity should be updated. Must be a fixed fee. */ + fun priceId(priceId: JsonField) = apply { this.priceId = priceId } + + fun quantity(quantity: Double) = quantity(JsonField.of(quantity)) - fun quantity(quantity: Double) = apply { this.quantity = quantity } + fun quantity(quantity: JsonField) = apply { this.quantity = quantity } /** * Determines when the change takes effect. Note that if `effective_date` is specified, * this defaults to `effective_date`. Otherwise, this defaults to `immediate` unless * it's explicitly set to `upcoming_invoice. */ - fun changeOption(changeOption: ChangeOption?) = apply { - this.changeOption = changeOption - } + fun changeOption(changeOption: ChangeOption) = changeOption(JsonField.of(changeOption)) /** * Determines when the change takes effect. Note that if `effective_date` is specified, * this defaults to `effective_date`. Otherwise, this defaults to `immediate` unless * it's explicitly set to `upcoming_invoice. */ - fun changeOption(changeOption: Optional) = - changeOption(changeOption.orElse(null)) + fun changeOption(changeOption: JsonField) = apply { + this.changeOption = changeOption + } /** * The date that the quantity change should take effect, localized to the customer's * timezone. Ifthis parameter is not passed in, the quantity change is effective * according to `change_option`. */ - fun effectiveDate(effectiveDate: LocalDate?) = apply { - this.effectiveDate = effectiveDate - } + fun effectiveDate(effectiveDate: LocalDate?) = + effectiveDate(JsonField.ofNullable(effectiveDate)) /** * The date that the quantity change should take effect, localized to the customer's @@ -171,6 +251,15 @@ constructor( fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.orElse(null)) + /** + * The date that the quantity change should take effect, localized to the customer's + * timezone. Ifthis parameter is not passed in, the quantity change is effective + * according to `change_option`. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + this.effectiveDate = effectiveDate + } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -251,22 +340,28 @@ constructor( /** Price for which the quantity should be updated. Must be a fixed fee. */ fun priceId(priceId: String) = apply { body.priceId(priceId) } + /** Price for which the quantity should be updated. Must be a fixed fee. */ + fun priceId(priceId: JsonField) = apply { body.priceId(priceId) } + fun quantity(quantity: Double) = apply { body.quantity(quantity) } + fun quantity(quantity: JsonField) = apply { body.quantity(quantity) } + /** * Determines when the change takes effect. Note that if `effective_date` is specified, this * defaults to `effective_date`. Otherwise, this defaults to `immediate` unless it's * explicitly set to `upcoming_invoice. */ - fun changeOption(changeOption: ChangeOption?) = apply { body.changeOption(changeOption) } + fun changeOption(changeOption: ChangeOption) = apply { body.changeOption(changeOption) } /** * Determines when the change takes effect. Note that if `effective_date` is specified, this * defaults to `effective_date`. Otherwise, this defaults to `immediate` unless it's * explicitly set to `upcoming_invoice. */ - fun changeOption(changeOption: Optional) = - changeOption(changeOption.orElse(null)) + fun changeOption(changeOption: JsonField) = apply { + body.changeOption(changeOption) + } /** * The date that the quantity change should take effect, localized to the customer's @@ -283,6 +378,34 @@ constructor( fun effectiveDate(effectiveDate: Optional) = effectiveDate(effectiveDate.orElse(null)) + /** + * The date that the quantity change should take effect, localized to the customer's + * timezone. Ifthis parameter is not passed in, the quantity change is effective according + * to `change_option`. + */ + fun effectiveDate(effectiveDate: JsonField) = apply { + body.effectiveDate(effectiveDate) + } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -381,25 +504,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionUpdateFixedFeeQuantityParams = SubscriptionUpdateFixedFeeQuantityParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt index 0330da3e..8294bd5d 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateFixedFeeQuantityResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -454,7 +474,10 @@ private constructor( ) = apply { id = subscriptionUpdateFixedFeeQuantityResponse.id activePlanPhaseOrder = subscriptionUpdateFixedFeeQuantityResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionUpdateFixedFeeQuantityResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionUpdateFixedFeeQuantityResponse.adjustmentIntervals.map { + it.toMutableList() + } autoCollection = subscriptionUpdateFixedFeeQuantityResponse.autoCollection billingCycleAnchorConfiguration = subscriptionUpdateFixedFeeQuantityResponse.billingCycleAnchorConfiguration @@ -466,17 +489,29 @@ private constructor( subscriptionUpdateFixedFeeQuantityResponse.currentBillingPeriodStartDate customer = subscriptionUpdateFixedFeeQuantityResponse.customer defaultInvoiceMemo = subscriptionUpdateFixedFeeQuantityResponse.defaultInvoiceMemo - discountIntervals = subscriptionUpdateFixedFeeQuantityResponse.discountIntervals + discountIntervals = + subscriptionUpdateFixedFeeQuantityResponse.discountIntervals.map { + it.toMutableList() + } endDate = subscriptionUpdateFixedFeeQuantityResponse.endDate fixedFeeQuantitySchedule = - subscriptionUpdateFixedFeeQuantityResponse.fixedFeeQuantitySchedule + subscriptionUpdateFixedFeeQuantityResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionUpdateFixedFeeQuantityResponse.invoicingThreshold - maximumIntervals = subscriptionUpdateFixedFeeQuantityResponse.maximumIntervals + maximumIntervals = + subscriptionUpdateFixedFeeQuantityResponse.maximumIntervals.map { + it.toMutableList() + } metadata = subscriptionUpdateFixedFeeQuantityResponse.metadata - minimumIntervals = subscriptionUpdateFixedFeeQuantityResponse.minimumIntervals + minimumIntervals = + subscriptionUpdateFixedFeeQuantityResponse.minimumIntervals.map { + it.toMutableList() + } netTerms = subscriptionUpdateFixedFeeQuantityResponse.netTerms plan = subscriptionUpdateFixedFeeQuantityResponse.plan - priceIntervals = subscriptionUpdateFixedFeeQuantityResponse.priceIntervals + priceIntervals = + subscriptionUpdateFixedFeeQuantityResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionUpdateFixedFeeQuantityResponse.redeemedCoupon startDate = subscriptionUpdateFixedFeeQuantityResponse.startDate status = subscriptionUpdateFixedFeeQuantityResponse.status @@ -489,9 +524,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -504,7 +548,21 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } + } + + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } } /** @@ -512,7 +570,24 @@ private constructor( * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -558,8 +633,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -576,8 +659,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -632,8 +723,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -649,11 +747,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -663,10 +778,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } + + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -678,7 +812,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -701,7 +849,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -740,11 +902,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } + } + + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -785,31 +964,55 @@ private constructor( fun build(): SubscriptionUpdateFixedFeeQuantityResponse = SubscriptionUpdateFixedFeeQuantityResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -850,20 +1053,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -891,18 +1100,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -918,6 +1128,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -925,11 +1150,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the adjustment interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -963,11 +1206,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1270,11 +1516,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1282,12 +1528,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1295,15 +1541,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1333,13 +1579,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1347,7 +1593,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1387,7 +1634,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1405,9 +1666,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1415,7 +1685,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1444,13 +1717,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1582,16 +1866,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1599,7 +1883,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1607,15 +1891,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1645,13 +1929,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1659,7 +1943,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1685,7 +1972,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1718,9 +2019,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1728,7 +2038,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1757,13 +2070,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1894,16 +2218,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1911,21 +2235,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1955,20 +2281,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1994,7 +2321,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2012,9 +2353,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2022,7 +2372,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2066,13 +2419,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2209,16 +2573,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2226,24 +2590,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2274,21 +2640,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2314,7 +2681,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2353,9 +2734,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2363,7 +2753,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2392,14 +2785,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2530,16 +2934,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2547,21 +2951,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2591,20 +2997,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2629,7 +3036,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2662,9 +3083,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2672,7 +3102,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2701,13 +3134,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2840,19 +3284,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2878,7 +3322,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2913,7 +3357,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2925,7 +3382,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2954,7 +3424,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3206,25 +3676,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3253,19 +3731,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3288,7 +3768,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3298,9 +3792,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3309,7 +3818,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3346,12 +3858,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3474,25 +3994,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3521,18 +4047,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3547,7 +4077,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3557,9 +4101,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3568,7 +4127,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3618,12 +4180,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3749,26 +4319,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3797,18 +4375,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3822,7 +4402,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3832,9 +4426,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3843,7 +4452,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3895,12 +4507,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4004,13 +4624,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4037,10 +4661,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4052,7 +4676,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4091,10 +4717,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4164,24 +4790,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4209,17 +4841,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4232,7 +4865,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4242,11 +4889,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4294,11 +4959,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4448,24 +5119,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4493,17 +5170,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4516,7 +5194,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4526,11 +5218,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4578,11 +5288,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4917,10 +5633,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4929,7 +5647,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4938,13 +5656,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4952,7 +5673,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5182,13 +5904,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5219,15 +5943,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5237,7 +5962,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5261,8 +5987,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5278,8 +6012,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5294,7 +6037,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5307,8 +6056,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5316,7 +6073,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5778,6 +6557,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5813,14 +6657,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5848,11 +6701,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5878,9 +6733,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5931,9 +6786,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5998,11 +6855,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6028,9 +6889,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6045,7 +6906,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6076,9 +6939,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6178,7 +7041,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6202,7 +7067,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6211,7 +7076,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6234,7 +7101,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt index 726c04e8..55969bad 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateParams.kt @@ -7,6 +7,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter import com.fasterxml.jackson.annotation.JsonCreator import com.fasterxml.jackson.annotation.JsonProperty import com.withorb.api.core.ExcludeMissing +import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.http.Headers @@ -16,6 +18,10 @@ import com.withorb.api.core.toImmutable import java.util.Objects import java.util.Optional +/** + * This endpoint can be used to update the `metadata`, `net terms`, `auto_collection`, + * `invoicing_threshold`, and `default_invoice_memo` properties on a subscription. + */ class SubscriptionUpdateParams constructor( private val subscriptionId: String, @@ -59,12 +65,45 @@ constructor( */ fun netTerms(): Optional = body.netTerms() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * Determines whether issued invoices for this subscription will automatically be charged with + * the saved payment method on the due date. This property defaults to the plan's behavior. + */ + fun _autoCollection(): JsonField = body._autoCollection() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun _defaultInvoiceMemo(): JsonField = body._defaultInvoiceMemo() + + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued for + * the subscription. If not specified, invoices will only be issued at the end of the billing + * period. + */ + fun _invoicingThreshold(): JsonField = body._invoicingThreshold() + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by setting + * the value to `null`, and the entire metadata mapping can be cleared by setting `metadata` to + * `null`. + */ + fun _metadata(): JsonField = body._metadata() + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun _netTerms(): JsonField = body._netTerms() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionUpdateBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -82,29 +121,78 @@ constructor( class SubscriptionUpdateBody @JsonCreator internal constructor( - @JsonProperty("auto_collection") private val autoCollection: Boolean?, - @JsonProperty("default_invoice_memo") private val defaultInvoiceMemo: String?, - @JsonProperty("invoicing_threshold") private val invoicingThreshold: String?, - @JsonProperty("metadata") private val metadata: Metadata?, - @JsonProperty("net_terms") private val netTerms: Long?, + @JsonProperty("auto_collection") + @ExcludeMissing + private val autoCollection: JsonField = JsonMissing.of(), + @JsonProperty("default_invoice_memo") + @ExcludeMissing + private val defaultInvoiceMemo: JsonField = JsonMissing.of(), + @JsonProperty("invoicing_threshold") + @ExcludeMissing + private val invoicingThreshold: JsonField = JsonMissing.of(), + @JsonProperty("metadata") + @ExcludeMissing + private val metadata: JsonField = JsonMissing.of(), + @JsonProperty("net_terms") + @ExcludeMissing + private val netTerms: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. + */ + fun autoCollection(): Optional = + Optional.ofNullable(autoCollection.getNullable("auto_collection")) + + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(): Optional = + Optional.ofNullable(defaultInvoiceMemo.getNullable("default_invoice_memo")) + + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued + * for the subscription. If not specified, invoices will only be issued at the end of the + * billing period. + */ + fun invoicingThreshold(): Optional = + Optional.ofNullable(invoicingThreshold.getNullable("invoicing_threshold")) + + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(): Optional = Optional.ofNullable(metadata.getNullable("metadata")) + + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(): Optional = Optional.ofNullable(netTerms.getNullable("net_terms")) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. */ @JsonProperty("auto_collection") - fun autoCollection(): Optional = Optional.ofNullable(autoCollection) + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. */ @JsonProperty("default_invoice_memo") - fun defaultInvoiceMemo(): Optional = Optional.ofNullable(defaultInvoiceMemo) + @ExcludeMissing + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** * When this subscription's accrued usage reaches this threshold, an invoice will be issued @@ -112,26 +200,40 @@ constructor( * billing period. */ @JsonProperty("invoicing_threshold") - fun invoicingThreshold(): Optional = Optional.ofNullable(invoicingThreshold) + @ExcludeMissing + fun _invoicingThreshold(): JsonField = invoicingThreshold /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting * `metadata` to `null`. */ - @JsonProperty("metadata") fun metadata(): Optional = Optional.ofNullable(metadata) + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") fun netTerms(): Optional = Optional.ofNullable(netTerms) + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionUpdateBody = apply { + if (!validated) { + autoCollection() + defaultInvoiceMemo() + invoicingThreshold() + metadata().map { it.validate() } + netTerms() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -141,11 +243,11 @@ constructor( class Builder { - private var autoCollection: Boolean? = null - private var defaultInvoiceMemo: String? = null - private var invoicingThreshold: String? = null - private var metadata: Metadata? = null - private var netTerms: Long? = null + private var autoCollection: JsonField = JsonMissing.of() + private var defaultInvoiceMemo: JsonField = JsonMissing.of() + private var invoicingThreshold: JsonField = JsonMissing.of() + private var metadata: JsonField = JsonMissing.of() + private var netTerms: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -163,9 +265,8 @@ constructor( * charged with the saved payment method on the due date. This property defaults to the * plan's behavior. */ - fun autoCollection(autoCollection: Boolean?) = apply { - this.autoCollection = autoCollection - } + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) /** * Determines whether issued invoices for this subscription will automatically be @@ -183,13 +284,21 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Determines whether issued invoices for this subscription will automatically be + * charged with the saved payment method on the due date. This property defaults to the + * plan's behavior. + */ + fun autoCollection(autoCollection: JsonField) = apply { + this.autoCollection = autoCollection + } + /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = apply { - this.defaultInvoiceMemo = defaultInvoiceMemo - } + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) /** * Determines the default memo on this subscription's invoices. Note that if this is not @@ -198,14 +307,21 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + this.defaultInvoiceMemo = defaultInvoiceMemo + } + /** * When this subscription's accrued usage reaches this threshold, an invoice will be * issued for the subscription. If not specified, invoices will only be issued at the * end of the billing period. */ - fun invoicingThreshold(invoicingThreshold: String?) = apply { - this.invoicingThreshold = invoicingThreshold - } + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) /** * When this subscription's accrued usage reaches this threshold, an invoice will be @@ -215,12 +331,21 @@ constructor( fun invoicingThreshold(invoicingThreshold: Optional) = invoicingThreshold(invoicingThreshold.orElse(null)) + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be + * issued for the subscription. If not specified, invoices will only be issued at the + * end of the billing period. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + this.invoicingThreshold = invoicingThreshold + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by * setting `metadata` to `null`. */ - fun metadata(metadata: Metadata?) = apply { this.metadata = metadata } + fun metadata(metadata: Metadata?) = metadata(JsonField.ofNullable(metadata)) /** * User-specified key/value pairs for the resource. Individual keys can be removed by @@ -229,13 +354,20 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by + * setting `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { this.metadata = metadata } + /** * Determines the difference between the invoice issue date for subscription invoices as * the date that they are due. A value of `0` here represents that the invoice is due on * issue, whereas a value of `30` represents that the customer has a month to pay the * invoice. */ - fun netTerms(netTerms: Long?) = apply { this.netTerms = netTerms } + fun netTerms(netTerms: Long?) = netTerms(JsonField.ofNullable(netTerms)) /** * Determines the difference between the invoice issue date for subscription invoices as @@ -254,6 +386,14 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + /** + * Determines the difference between the invoice issue date for subscription invoices as + * the date that they are due. A value of `0` here represents that the invoice is due on + * issue, whereas a value of `30` represents that the customer has a month to pay the + * invoice. + */ + fun netTerms(netTerms: JsonField) = apply { this.netTerms = netTerms } + fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() putAllAdditionalProperties(additionalProperties) @@ -350,6 +490,15 @@ constructor( fun autoCollection(autoCollection: Optional) = autoCollection(autoCollection.orElse(null) as Boolean?) + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. + */ + fun autoCollection(autoCollection: JsonField) = apply { + body.autoCollection(autoCollection) + } + /** * Determines the default memo on this subscription's invoices. Note that if this is not * provided, it is determined by the plan configuration. @@ -365,6 +514,14 @@ constructor( fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) + /** + * Determines the default memo on this subscription's invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: JsonField) = apply { + body.defaultInvoiceMemo(defaultInvoiceMemo) + } + /** * When this subscription's accrued usage reaches this threshold, an invoice will be issued * for the subscription. If not specified, invoices will only be issued at the end of the @@ -382,6 +539,15 @@ constructor( fun invoicingThreshold(invoicingThreshold: Optional) = invoicingThreshold(invoicingThreshold.orElse(null)) + /** + * When this subscription's accrued usage reaches this threshold, an invoice will be issued + * for the subscription. If not specified, invoices will only be issued at the end of the + * billing period. + */ + fun invoicingThreshold(invoicingThreshold: JsonField) = apply { + body.invoicingThreshold(invoicingThreshold) + } + /** * User-specified key/value pairs for the resource. Individual keys can be removed by * setting the value to `null`, and the entire metadata mapping can be cleared by setting @@ -396,6 +562,13 @@ constructor( */ fun metadata(metadata: Optional) = metadata(metadata.orElse(null)) + /** + * User-specified key/value pairs for the resource. Individual keys can be removed by + * setting the value to `null`, and the entire metadata mapping can be cleared by setting + * `metadata` to `null`. + */ + fun metadata(metadata: JsonField) = apply { body.metadata(metadata) } + /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, @@ -418,6 +591,32 @@ constructor( @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 fun netTerms(netTerms: Optional) = netTerms(netTerms.orElse(null) as Long?) + /** + * Determines the difference between the invoice issue date for subscription invoices as the + * date that they are due. A value of `0` here represents that the invoice is due on issue, + * whereas a value of `30` represents that the customer has a month to pay the invoice. + */ + fun netTerms(netTerms: JsonField) = apply { body.netTerms(netTerms) } + + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } + fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() putAllAdditionalHeaders(additionalHeaders) @@ -516,25 +715,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionUpdateParams = SubscriptionUpdateParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, @@ -561,6 +741,14 @@ constructor( @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): Metadata = apply { + if (!validated) { + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt index 57622f08..eb8c1086 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialParams.kt @@ -18,6 +18,7 @@ import com.withorb.api.core.BaseSerializer import com.withorb.api.core.Enum import com.withorb.api.core.ExcludeMissing import com.withorb.api.core.JsonField +import com.withorb.api.core.JsonMissing import com.withorb.api.core.JsonValue import com.withorb.api.core.NoAutoDetect import com.withorb.api.core.getOrThrow @@ -30,6 +31,24 @@ import java.time.OffsetDateTime import java.util.Objects import java.util.Optional +/** + * This endpoint is used to update the trial end date for a subscription. The new trial end date + * must be within the time range of the current plan (i.e. the new trial end date must be on or + * after the subscription's start date on the current plan, and on or before the subscription end + * date). + * + * In order to retroactively remove a trial completely, the end date can be set to the transition + * date of the subscription to this plan (or, if this is the first plan for this subscription, the + * subscription's start date). In order to end a trial immediately, the keyword `immediate` can be + * provided as the trial end date. + * + * By default, Orb will shift only the trial end date (and price intervals that start or end on the + * previous trial end date), and leave all other future price intervals untouched. If the `shift` + * parameter is set to `true`, Orb will shift all subsequent price and adjustment intervals by the + * same amount as the trial end date shift (so, e.g., if a plan change is scheduled or an add-on + * price was added, that change will be pushed back by the same amount of time the trial is + * extended). + */ class SubscriptionUpdateTrialParams constructor( private val subscriptionId: String, @@ -52,12 +71,24 @@ constructor( */ fun shift(): Optional = body.shift() - fun _additionalHeaders(): Headers = additionalHeaders + /** + * The new date that the trial should end, or the literal string `immediate` to end the trial + * immediately. + */ + fun _trialEndDate(): JsonField = body._trialEndDate() - fun _additionalQueryParams(): QueryParams = additionalQueryParams + /** + * If true, shifts subsequent price and adjustment intervals (preserving their durations, but + * adjusting their absolute dates). + */ + fun _shift(): JsonField = body._shift() fun _additionalBodyProperties(): Map = body._additionalProperties() + fun _additionalHeaders(): Headers = additionalHeaders + + fun _additionalQueryParams(): QueryParams = additionalQueryParams + @JvmSynthetic internal fun getBody(): SubscriptionUpdateTrialBody = body @JvmSynthetic internal fun getHeaders(): Headers = additionalHeaders @@ -75,8 +106,12 @@ constructor( class SubscriptionUpdateTrialBody @JsonCreator internal constructor( - @JsonProperty("trial_end_date") private val trialEndDate: TrialEndDate, - @JsonProperty("shift") private val shift: Boolean?, + @JsonProperty("trial_end_date") + @ExcludeMissing + private val trialEndDate: JsonField = JsonMissing.of(), + @JsonProperty("shift") + @ExcludeMissing + private val shift: JsonField = JsonMissing.of(), @JsonAnySetter private val additionalProperties: Map = immutableEmptyMap(), ) { @@ -85,18 +120,42 @@ constructor( * The new date that the trial should end, or the literal string `immediate` to end the * trial immediately. */ - @JsonProperty("trial_end_date") fun trialEndDate(): TrialEndDate = trialEndDate + fun trialEndDate(): TrialEndDate = trialEndDate.getRequired("trial_end_date") + + /** + * If true, shifts subsequent price and adjustment intervals (preserving their durations, + * but adjusting their absolute dates). + */ + fun shift(): Optional = Optional.ofNullable(shift.getNullable("shift")) + + /** + * The new date that the trial should end, or the literal string `immediate` to end the + * trial immediately. + */ + @JsonProperty("trial_end_date") + @ExcludeMissing + fun _trialEndDate(): JsonField = trialEndDate /** * If true, shifts subsequent price and adjustment intervals (preserving their durations, * but adjusting their absolute dates). */ - @JsonProperty("shift") fun shift(): Optional = Optional.ofNullable(shift) + @JsonProperty("shift") @ExcludeMissing fun _shift(): JsonField = shift @JsonAnyGetter @ExcludeMissing fun _additionalProperties(): Map = additionalProperties + private var validated: Boolean = false + + fun validate(): SubscriptionUpdateTrialBody = apply { + if (!validated) { + trialEndDate() + shift() + validated = true + } + } + fun toBuilder() = Builder().from(this) companion object { @@ -106,8 +165,8 @@ constructor( class Builder { - private var trialEndDate: TrialEndDate? = null - private var shift: Boolean? = null + private var trialEndDate: JsonField? = null + private var shift: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -122,36 +181,33 @@ constructor( * The new date that the trial should end, or the literal string `immediate` to end the * trial immediately. */ - fun trialEndDate(trialEndDate: TrialEndDate) = apply { - this.trialEndDate = trialEndDate - } + fun trialEndDate(trialEndDate: TrialEndDate) = trialEndDate(JsonField.of(trialEndDate)) - fun trialEndDate(offsetDateTime: OffsetDateTime) = apply { - this.trialEndDate = TrialEndDate.ofOffsetDateTime(offsetDateTime) + /** + * The new date that the trial should end, or the literal string `immediate` to end the + * trial immediately. + */ + fun trialEndDate(trialEndDate: JsonField) = apply { + this.trialEndDate = trialEndDate } - fun trialEndDate(unionMember1: TrialEndDate.UnionMember1) = apply { - this.trialEndDate = TrialEndDate.ofUnionMember1(unionMember1) - } + fun trialEndDate(offsetDateTime: OffsetDateTime) = + trialEndDate(TrialEndDate.ofOffsetDateTime(offsetDateTime)) - /** - * If true, shifts subsequent price and adjustment intervals (preserving their - * durations, but adjusting their absolute dates). - */ - fun shift(shift: Boolean?) = apply { this.shift = shift } + fun trialEndDate(unionMember1: TrialEndDate.UnionMember1) = + trialEndDate(TrialEndDate.ofUnionMember1(unionMember1)) /** * If true, shifts subsequent price and adjustment intervals (preserving their * durations, but adjusting their absolute dates). */ - fun shift(shift: Boolean) = shift(shift as Boolean?) + fun shift(shift: Boolean) = shift(JsonField.of(shift)) /** * If true, shifts subsequent price and adjustment intervals (preserving their * durations, but adjusting their absolute dates). */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun shift(shift: Optional) = shift(shift.orElse(null) as Boolean?) + fun shift(shift: JsonField) = apply { this.shift = shift } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -230,6 +286,14 @@ constructor( */ fun trialEndDate(trialEndDate: TrialEndDate) = apply { body.trialEndDate(trialEndDate) } + /** + * The new date that the trial should end, or the literal string `immediate` to end the + * trial immediately. + */ + fun trialEndDate(trialEndDate: JsonField) = apply { + body.trialEndDate(trialEndDate) + } + fun trialEndDate(offsetDateTime: OffsetDateTime) = apply { body.trialEndDate(offsetDateTime) } @@ -242,20 +306,32 @@ constructor( * If true, shifts subsequent price and adjustment intervals (preserving their durations, * but adjusting their absolute dates). */ - fun shift(shift: Boolean?) = apply { body.shift(shift) } + fun shift(shift: Boolean) = apply { body.shift(shift) } /** * If true, shifts subsequent price and adjustment intervals (preserving their durations, * but adjusting their absolute dates). */ - fun shift(shift: Boolean) = shift(shift as Boolean?) + fun shift(shift: JsonField) = apply { body.shift(shift) } - /** - * If true, shifts subsequent price and adjustment intervals (preserving their durations, - * but adjusting their absolute dates). - */ - @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 - fun shift(shift: Optional) = shift(shift.orElse(null) as Boolean?) + fun additionalBodyProperties(additionalBodyProperties: Map) = apply { + body.additionalProperties(additionalBodyProperties) + } + + fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { + body.putAdditionalProperty(key, value) + } + + fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = + apply { + body.putAllAdditionalProperties(additionalBodyProperties) + } + + fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } + + fun removeAllAdditionalBodyProperties(keys: Set) = apply { + body.removeAllAdditionalProperties(keys) + } fun additionalHeaders(additionalHeaders: Headers) = apply { this.additionalHeaders.clear() @@ -355,25 +431,6 @@ constructor( additionalQueryParams.removeAll(keys) } - fun additionalBodyProperties(additionalBodyProperties: Map) = apply { - body.additionalProperties(additionalBodyProperties) - } - - fun putAdditionalBodyProperty(key: String, value: JsonValue) = apply { - body.putAdditionalProperty(key, value) - } - - fun putAllAdditionalBodyProperties(additionalBodyProperties: Map) = - apply { - body.putAllAdditionalProperties(additionalBodyProperties) - } - - fun removeAdditionalBodyProperty(key: String) = apply { body.removeAdditionalProperty(key) } - - fun removeAllAdditionalBodyProperties(keys: Set) = apply { - body.removeAllAdditionalProperties(keys) - } - fun build(): SubscriptionUpdateTrialParams = SubscriptionUpdateTrialParams( checkNotNull(subscriptionId) { "`subscriptionId` is required but was not set" }, @@ -396,6 +453,8 @@ constructor( private val _json: JsonValue? = null, ) { + private var validated: Boolean = false + fun offsetDateTime(): Optional = Optional.ofNullable(offsetDateTime) fun unionMember1(): Optional = Optional.ofNullable(unionMember1) @@ -418,6 +477,15 @@ constructor( } } + fun validate(): TrialEndDate = apply { + if (!validated) { + if (offsetDateTime == null && unionMember1 == null) { + throw OrbInvalidDataException("Unknown TrialEndDate: $_json") + } + validated = true + } + } + override fun equals(other: Any?): Boolean { if (this === other) { return true diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt index f842f301..fdd99415 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUpdateTrialResponse.kt @@ -242,37 +242,44 @@ private constructor( fun trialInfo(): TrialInfo = trialInfo.getRequired("trial_info") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The current plan phase that is active, only if the subscription's plan has phases. */ @JsonProperty("active_plan_phase_order") @ExcludeMissing - fun _activePlanPhaseOrder() = activePlanPhaseOrder + fun _activePlanPhaseOrder(): JsonField = activePlanPhaseOrder /** The adjustment intervals for this subscription. */ @JsonProperty("adjustment_intervals") @ExcludeMissing - fun _adjustmentIntervals() = adjustmentIntervals + fun _adjustmentIntervals(): JsonField> = adjustmentIntervals /** * Determines whether issued invoices for this subscription will automatically be charged with * the saved payment method on the due date. This property defaults to the plan's behavior. If * null, defaults to the customer's setting. */ - @JsonProperty("auto_collection") @ExcludeMissing fun _autoCollection() = autoCollection + @JsonProperty("auto_collection") + @ExcludeMissing + fun _autoCollection(): JsonField = autoCollection @JsonProperty("billing_cycle_anchor_configuration") @ExcludeMissing - fun _billingCycleAnchorConfiguration() = billingCycleAnchorConfiguration + fun _billingCycleAnchorConfiguration(): JsonField = + billingCycleAnchorConfiguration /** * The day of the month on which the billing cycle is anchored. If the maximum number of days in * a month is greater than this value, the last day of the month is the billing cycle day (e.g. * billing_cycle_day=31 for April means the billing period begins on the 30th. */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay - @JsonProperty("created_at") @ExcludeMissing fun _createdAt() = createdAt + @JsonProperty("created_at") + @ExcludeMissing + fun _createdAt(): JsonField = createdAt /** * The end of the current billing period. This is an exclusive timestamp, such that the instant @@ -281,7 +288,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -290,7 +297,7 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = currentBillingPeriodStartDate /** * A customer is a buyer of your products, and the other party to the billing relationship. @@ -310,7 +317,7 @@ private constructor( * timezone. See [Timezone localization](../guides/product-catalog/timezones.md) for information * on what this timezone parameter influences within Orb. */ - @JsonProperty("customer") @ExcludeMissing fun _customer() = customer + @JsonProperty("customer") @ExcludeMissing fun _customer(): JsonField = customer /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -318,60 +325,73 @@ private constructor( */ @JsonProperty("default_invoice_memo") @ExcludeMissing - fun _defaultInvoiceMemo() = defaultInvoiceMemo + fun _defaultInvoiceMemo(): JsonField = defaultInvoiceMemo /** The discount intervals for this subscription. */ - @JsonProperty("discount_intervals") @ExcludeMissing fun _discountIntervals() = discountIntervals + @JsonProperty("discount_intervals") + @ExcludeMissing + fun _discountIntervals(): JsonField> = discountIntervals /** The date Orb stops billing for this subscription. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") @ExcludeMissing fun _endDate(): JsonField = endDate @JsonProperty("fixed_fee_quantity_schedule") @ExcludeMissing - fun _fixedFeeQuantitySchedule() = fixedFeeQuantitySchedule + fun _fixedFeeQuantitySchedule(): JsonField> = + fixedFeeQuantitySchedule @JsonProperty("invoicing_threshold") @ExcludeMissing - fun _invoicingThreshold() = invoicingThreshold + fun _invoicingThreshold(): JsonField = invoicingThreshold /** The maximum intervals for this subscription. */ - @JsonProperty("maximum_intervals") @ExcludeMissing fun _maximumIntervals() = maximumIntervals + @JsonProperty("maximum_intervals") + @ExcludeMissing + fun _maximumIntervals(): JsonField> = maximumIntervals /** * User specified key-value pairs for the resource. If not present, this defaults to an empty * dictionary. Individual keys can be removed by setting the value to `null`, and the entire * metadata mapping can be cleared by setting `metadata` to `null`. */ - @JsonProperty("metadata") @ExcludeMissing fun _metadata() = metadata + @JsonProperty("metadata") @ExcludeMissing fun _metadata(): JsonField = metadata /** The minimum intervals for this subscription. */ - @JsonProperty("minimum_intervals") @ExcludeMissing fun _minimumIntervals() = minimumIntervals + @JsonProperty("minimum_intervals") + @ExcludeMissing + fun _minimumIntervals(): JsonField> = minimumIntervals /** * Determines the difference between the invoice issue date for subscription invoices as the * date that they are due. A value of `0` here represents that the invoice is due on issue, * whereas a value of `30` represents that the customer has a month to pay the invoice. */ - @JsonProperty("net_terms") @ExcludeMissing fun _netTerms() = netTerms + @JsonProperty("net_terms") @ExcludeMissing fun _netTerms(): JsonField = netTerms /** * The [Plan](../guides/core-concepts.mdx#plan-and-price) resource represents a plan that can be * subscribed to by a customer. Plans define the billing behavior of the subscription. You can * see more about how to configure prices in the [Price resource](/reference/price). */ - @JsonProperty("plan") @ExcludeMissing fun _plan() = plan + @JsonProperty("plan") @ExcludeMissing fun _plan(): JsonField = plan /** The price intervals for this subscription. */ - @JsonProperty("price_intervals") @ExcludeMissing fun _priceIntervals() = priceIntervals + @JsonProperty("price_intervals") + @ExcludeMissing + fun _priceIntervals(): JsonField> = priceIntervals - @JsonProperty("redeemed_coupon") @ExcludeMissing fun _redeemedCoupon() = redeemedCoupon + @JsonProperty("redeemed_coupon") + @ExcludeMissing + fun _redeemedCoupon(): JsonField = redeemedCoupon /** The date Orb starts billing for this subscription. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate - @JsonProperty("status") @ExcludeMissing fun _status() = status + @JsonProperty("status") @ExcludeMissing fun _status(): JsonField = status - @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo() = trialInfo + @JsonProperty("trial_info") @ExcludeMissing fun _trialInfo(): JsonField = trialInfo @JsonAnyGetter @ExcludeMissing @@ -419,33 +439,33 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var activePlanPhaseOrder: JsonField = JsonMissing.of() - private var adjustmentIntervals: JsonField> = JsonMissing.of() - private var autoCollection: JsonField = JsonMissing.of() - private var billingCycleAnchorConfiguration: JsonField = - JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var createdAt: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var customer: JsonField = JsonMissing.of() - private var defaultInvoiceMemo: JsonField = JsonMissing.of() - private var discountIntervals: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantitySchedule: JsonField> = - JsonMissing.of() - private var invoicingThreshold: JsonField = JsonMissing.of() - private var maximumIntervals: JsonField> = JsonMissing.of() - private var metadata: JsonField = JsonMissing.of() - private var minimumIntervals: JsonField> = JsonMissing.of() - private var netTerms: JsonField = JsonMissing.of() - private var plan: JsonField = JsonMissing.of() - private var priceIntervals: JsonField> = JsonMissing.of() - private var redeemedCoupon: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var status: JsonField = JsonMissing.of() - private var trialInfo: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var activePlanPhaseOrder: JsonField? = null + private var adjustmentIntervals: JsonField>? = null + private var autoCollection: JsonField? = null + private var billingCycleAnchorConfiguration: JsonField? = + null + private var billingCycleDay: JsonField? = null + private var createdAt: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var customer: JsonField? = null + private var defaultInvoiceMemo: JsonField? = null + private var discountIntervals: JsonField>? = null + private var endDate: JsonField? = null + private var fixedFeeQuantitySchedule: JsonField>? = + null + private var invoicingThreshold: JsonField? = null + private var maximumIntervals: JsonField>? = null + private var metadata: JsonField? = null + private var minimumIntervals: JsonField>? = null + private var netTerms: JsonField? = null + private var plan: JsonField? = null + private var priceIntervals: JsonField>? = null + private var redeemedCoupon: JsonField? = null + private var startDate: JsonField? = null + private var status: JsonField? = null + private var trialInfo: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -453,7 +473,8 @@ private constructor( apply { id = subscriptionUpdateTrialResponse.id activePlanPhaseOrder = subscriptionUpdateTrialResponse.activePlanPhaseOrder - adjustmentIntervals = subscriptionUpdateTrialResponse.adjustmentIntervals + adjustmentIntervals = + subscriptionUpdateTrialResponse.adjustmentIntervals.map { it.toMutableList() } autoCollection = subscriptionUpdateTrialResponse.autoCollection billingCycleAnchorConfiguration = subscriptionUpdateTrialResponse.billingCycleAnchorConfiguration @@ -465,16 +486,23 @@ private constructor( subscriptionUpdateTrialResponse.currentBillingPeriodStartDate customer = subscriptionUpdateTrialResponse.customer defaultInvoiceMemo = subscriptionUpdateTrialResponse.defaultInvoiceMemo - discountIntervals = subscriptionUpdateTrialResponse.discountIntervals + discountIntervals = + subscriptionUpdateTrialResponse.discountIntervals.map { it.toMutableList() } endDate = subscriptionUpdateTrialResponse.endDate - fixedFeeQuantitySchedule = subscriptionUpdateTrialResponse.fixedFeeQuantitySchedule + fixedFeeQuantitySchedule = + subscriptionUpdateTrialResponse.fixedFeeQuantitySchedule.map { + it.toMutableList() + } invoicingThreshold = subscriptionUpdateTrialResponse.invoicingThreshold - maximumIntervals = subscriptionUpdateTrialResponse.maximumIntervals + maximumIntervals = + subscriptionUpdateTrialResponse.maximumIntervals.map { it.toMutableList() } metadata = subscriptionUpdateTrialResponse.metadata - minimumIntervals = subscriptionUpdateTrialResponse.minimumIntervals + minimumIntervals = + subscriptionUpdateTrialResponse.minimumIntervals.map { it.toMutableList() } netTerms = subscriptionUpdateTrialResponse.netTerms plan = subscriptionUpdateTrialResponse.plan - priceIntervals = subscriptionUpdateTrialResponse.priceIntervals + priceIntervals = + subscriptionUpdateTrialResponse.priceIntervals.map { it.toMutableList() } redeemedCoupon = subscriptionUpdateTrialResponse.redeemedCoupon startDate = subscriptionUpdateTrialResponse.startDate status = subscriptionUpdateTrialResponse.status @@ -487,9 +515,18 @@ private constructor( fun id(id: JsonField) = apply { this.id = id } + /** The current plan phase that is active, only if the subscription's plan has phases. */ + fun activePlanPhaseOrder(activePlanPhaseOrder: Long?) = + activePlanPhaseOrder(JsonField.ofNullable(activePlanPhaseOrder)) + /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: Long) = - activePlanPhaseOrder(JsonField.of(activePlanPhaseOrder)) + activePlanPhaseOrder(activePlanPhaseOrder as Long?) + + /** The current plan phase that is active, only if the subscription's plan has phases. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun activePlanPhaseOrder(activePlanPhaseOrder: Optional) = + activePlanPhaseOrder(activePlanPhaseOrder.orElse(null) as Long?) /** The current plan phase that is active, only if the subscription's plan has phases. */ fun activePlanPhaseOrder(activePlanPhaseOrder: JsonField) = apply { @@ -502,15 +539,46 @@ private constructor( /** The adjustment intervals for this subscription. */ fun adjustmentIntervals(adjustmentIntervals: JsonField>) = apply { - this.adjustmentIntervals = adjustmentIntervals + this.adjustmentIntervals = adjustmentIntervals.map { it.toMutableList() } } + /** The adjustment intervals for this subscription. */ + fun addAdjustmentInterval(adjustmentInterval: AdjustmentInterval) = apply { + adjustmentIntervals = + (adjustmentIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(adjustmentInterval) + } + } + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean?) = + autoCollection(JsonField.ofNullable(autoCollection)) + + /** + * Determines whether issued invoices for this subscription will automatically be charged + * with the saved payment method on the due date. This property defaults to the plan's + * behavior. If null, defaults to the customer's setting. + */ + fun autoCollection(autoCollection: Boolean) = autoCollection(autoCollection as Boolean?) + /** * Determines whether issued invoices for this subscription will automatically be charged * with the saved payment method on the due date. This property defaults to the plan's * behavior. If null, defaults to the customer's setting. */ - fun autoCollection(autoCollection: Boolean) = autoCollection(JsonField.of(autoCollection)) + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun autoCollection(autoCollection: Optional) = + autoCollection(autoCollection.orElse(null) as Boolean?) /** * Determines whether issued invoices for this subscription will automatically be charged @@ -556,8 +624,16 @@ private constructor( * instant returned is not part of the billing period. Set to null for subscriptions that * are not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is not part of the billing period. Set to null for subscriptions that + * are not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -574,8 +650,16 @@ private constructor( * returned is exactly the beginning of the billing period. Set to null if the subscription * is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the instant + * returned is exactly the beginning of the billing period. Set to null if the subscription + * is not currently active. + */ + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: Optional) = + currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -630,8 +714,15 @@ private constructor( * Determines the default memo on this subscriptions' invoices. Note that if this is not * provided, it is determined by the plan configuration. */ - fun defaultInvoiceMemo(defaultInvoiceMemo: String) = - defaultInvoiceMemo(JsonField.of(defaultInvoiceMemo)) + fun defaultInvoiceMemo(defaultInvoiceMemo: String?) = + defaultInvoiceMemo(JsonField.ofNullable(defaultInvoiceMemo)) + + /** + * Determines the default memo on this subscriptions' invoices. Note that if this is not + * provided, it is determined by the plan configuration. + */ + fun defaultInvoiceMemo(defaultInvoiceMemo: Optional) = + defaultInvoiceMemo(defaultInvoiceMemo.orElse(null)) /** * Determines the default memo on this subscriptions' invoices. Note that if this is not @@ -647,11 +738,28 @@ private constructor( /** The discount intervals for this subscription. */ fun discountIntervals(discountIntervals: JsonField>) = apply { - this.discountIntervals = discountIntervals + this.discountIntervals = discountIntervals.map { it.toMutableList() } + } + + /** The discount intervals for this subscription. */ + fun addDiscountInterval(discountInterval: DiscountInterval) = apply { + discountIntervals = + (discountIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(discountInterval) + } } /** The date Orb stops billing for this subscription. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The date Orb stops billing for this subscription. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The date Orb stops billing for this subscription. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -661,10 +769,29 @@ private constructor( fun fixedFeeQuantitySchedule( fixedFeeQuantitySchedule: JsonField> - ) = apply { this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule } + ) = apply { + this.fixedFeeQuantitySchedule = fixedFeeQuantitySchedule.map { it.toMutableList() } + } + + fun addFixedFeeQuantitySchedule(fixedFeeQuantitySchedule: FixedFeeQuantitySchedule) = + apply { + this.fixedFeeQuantitySchedule = + (this.fixedFeeQuantitySchedule ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantitySchedule) + } + } - fun invoicingThreshold(invoicingThreshold: String) = - invoicingThreshold(JsonField.of(invoicingThreshold)) + fun invoicingThreshold(invoicingThreshold: String?) = + invoicingThreshold(JsonField.ofNullable(invoicingThreshold)) + + fun invoicingThreshold(invoicingThreshold: Optional) = + invoicingThreshold(invoicingThreshold.orElse(null)) fun invoicingThreshold(invoicingThreshold: JsonField) = apply { this.invoicingThreshold = invoicingThreshold @@ -676,7 +803,21 @@ private constructor( /** The maximum intervals for this subscription. */ fun maximumIntervals(maximumIntervals: JsonField>) = apply { - this.maximumIntervals = maximumIntervals + this.maximumIntervals = maximumIntervals.map { it.toMutableList() } + } + + /** The maximum intervals for this subscription. */ + fun addMaximumInterval(maximumInterval: MaximumInterval) = apply { + maximumIntervals = + (maximumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(maximumInterval) + } } /** @@ -699,7 +840,21 @@ private constructor( /** The minimum intervals for this subscription. */ fun minimumIntervals(minimumIntervals: JsonField>) = apply { - this.minimumIntervals = minimumIntervals + this.minimumIntervals = minimumIntervals.map { it.toMutableList() } + } + + /** The minimum intervals for this subscription. */ + fun addMinimumInterval(minimumInterval: MinimumInterval) = apply { + minimumIntervals = + (minimumIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(minimumInterval) + } } /** @@ -738,11 +893,28 @@ private constructor( /** The price intervals for this subscription. */ fun priceIntervals(priceIntervals: JsonField>) = apply { - this.priceIntervals = priceIntervals + this.priceIntervals = priceIntervals.map { it.toMutableList() } + } + + /** The price intervals for this subscription. */ + fun addPriceInterval(priceInterval: PriceInterval) = apply { + priceIntervals = + (priceIntervals ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(priceInterval) + } } - fun redeemedCoupon(redeemedCoupon: RedeemedCoupon) = - redeemedCoupon(JsonField.of(redeemedCoupon)) + fun redeemedCoupon(redeemedCoupon: RedeemedCoupon?) = + redeemedCoupon(JsonField.ofNullable(redeemedCoupon)) + + fun redeemedCoupon(redeemedCoupon: Optional) = + redeemedCoupon(redeemedCoupon.orElse(null)) fun redeemedCoupon(redeemedCoupon: JsonField) = apply { this.redeemedCoupon = redeemedCoupon @@ -783,31 +955,55 @@ private constructor( fun build(): SubscriptionUpdateTrialResponse = SubscriptionUpdateTrialResponse( - id, - activePlanPhaseOrder, - adjustmentIntervals.map { it.toImmutable() }, - autoCollection, - billingCycleAnchorConfiguration, - billingCycleDay, - createdAt, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - customer, - defaultInvoiceMemo, - discountIntervals.map { it.toImmutable() }, - endDate, - fixedFeeQuantitySchedule.map { it.toImmutable() }, - invoicingThreshold, - maximumIntervals.map { it.toImmutable() }, - metadata, - minimumIntervals.map { it.toImmutable() }, - netTerms, - plan, - priceIntervals.map { it.toImmutable() }, - redeemedCoupon, - startDate, - status, - trialInfo, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(activePlanPhaseOrder) { + "`activePlanPhaseOrder` is required but was not set" + }, + checkNotNull(adjustmentIntervals) { + "`adjustmentIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(autoCollection) { "`autoCollection` is required but was not set" }, + checkNotNull(billingCycleAnchorConfiguration) { + "`billingCycleAnchorConfiguration` is required but was not set" + }, + checkNotNull(billingCycleDay) { "`billingCycleDay` is required but was not set" }, + checkNotNull(createdAt) { "`createdAt` is required but was not set" }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(customer) { "`customer` is required but was not set" }, + checkNotNull(defaultInvoiceMemo) { + "`defaultInvoiceMemo` is required but was not set" + }, + checkNotNull(discountIntervals) { + "`discountIntervals` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantitySchedule) { + "`fixedFeeQuantitySchedule` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(invoicingThreshold) { + "`invoicingThreshold` is required but was not set" + }, + checkNotNull(maximumIntervals) { "`maximumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(metadata) { "`metadata` is required but was not set" }, + checkNotNull(minimumIntervals) { "`minimumIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(netTerms) { "`netTerms` is required but was not set" }, + checkNotNull(plan) { "`plan` is required but was not set" }, + checkNotNull(priceIntervals) { "`priceIntervals` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(redeemedCoupon) { "`redeemedCoupon` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(status) { "`status` is required but was not set" }, + checkNotNull(trialInfo) { "`trialInfo` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -848,20 +1044,26 @@ private constructor( /** The start date of the adjustment interval. */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("adjustment") @ExcludeMissing fun _adjustment() = adjustment + @JsonProperty("adjustment") + @ExcludeMissing + fun _adjustment(): JsonField = adjustment /** The price interval IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the adjustment interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the adjustment interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -889,18 +1091,19 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustment: JsonField = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustment: JsonField? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(adjustmentInterval: AdjustmentInterval) = apply { id = adjustmentInterval.id adjustment = adjustmentInterval.adjustment - appliesToPriceIntervalIds = adjustmentInterval.appliesToPriceIntervalIds + appliesToPriceIntervalIds = + adjustmentInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = adjustmentInterval.endDate startDate = adjustmentInterval.startDate additionalProperties = adjustmentInterval.additionalProperties.toMutableMap() @@ -916,6 +1119,21 @@ private constructor( this.adjustment = adjustment } + fun adjustment(amountDiscountAdjustment: Adjustment.AmountDiscountAdjustment) = + adjustment(Adjustment.ofAmountDiscountAdjustment(amountDiscountAdjustment)) + + fun adjustment(percentageDiscountAdjustment: Adjustment.PercentageDiscountAdjustment) = + adjustment(Adjustment.ofPercentageDiscountAdjustment(percentageDiscountAdjustment)) + + fun adjustment(usageDiscountAdjustment: Adjustment.UsageDiscountAdjustment) = + adjustment(Adjustment.ofUsageDiscountAdjustment(usageDiscountAdjustment)) + + fun adjustment(minimumAdjustment: Adjustment.MinimumAdjustment) = + adjustment(Adjustment.ofMinimumAdjustment(minimumAdjustment)) + + fun adjustment(maximumAdjustment: Adjustment.MaximumAdjustment) = + adjustment(Adjustment.ofMaximumAdjustment(maximumAdjustment)) + /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: List) = appliesToPriceIntervalIds(JsonField.of(appliesToPriceIntervalIds)) @@ -923,11 +1141,29 @@ private constructor( /** The price interval IDs that this adjustment applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval IDs that this adjustment applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + /** The end date of the adjustment interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the adjustment interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the adjustment interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -961,11 +1197,14 @@ private constructor( fun build(): AdjustmentInterval = AdjustmentInterval( - id, - adjustment, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustment) { "`adjustment` is required but was not set" }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1268,11 +1507,11 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** * The amount by which to discount the prices this adjustment applies to in a given @@ -1280,12 +1519,12 @@ private constructor( */ @JsonProperty("amount_discount") @ExcludeMissing - fun _amountDiscount() = amountDiscount + fun _amountDiscount(): JsonField = amountDiscount /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1293,15 +1532,15 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1331,13 +1570,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1345,7 +1584,8 @@ private constructor( id = amountDiscountAdjustment.id adjustmentType = amountDiscountAdjustment.adjustmentType amountDiscount = amountDiscountAdjustment.amountDiscount - appliesToPriceIds = amountDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + amountDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = amountDiscountAdjustment.isInvoiceLevel planPhaseOrder = amountDiscountAdjustment.planPhaseOrder reason = amountDiscountAdjustment.reason @@ -1385,7 +1625,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1403,9 +1657,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1413,7 +1676,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1442,13 +1708,24 @@ private constructor( fun build(): AmountDiscountAdjustment = AmountDiscountAdjustment( - id, - adjustmentType, - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1580,16 +1857,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1597,7 +1874,7 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The percentage (as a value between 0 and 1) by which to discount the price @@ -1605,15 +1882,15 @@ private constructor( */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -1643,13 +1920,13 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var percentageDiscount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1657,7 +1934,10 @@ private constructor( apply { id = percentageDiscountAdjustment.id adjustmentType = percentageDiscountAdjustment.adjustmentType - appliesToPriceIds = percentageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + percentageDiscountAdjustment.appliesToPriceIds.map { + it.toMutableList() + } isInvoiceLevel = percentageDiscountAdjustment.isInvoiceLevel percentageDiscount = percentageDiscountAdjustment.percentageDiscount planPhaseOrder = percentageDiscountAdjustment.planPhaseOrder @@ -1683,7 +1963,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -1716,9 +2010,18 @@ private constructor( this.percentageDiscount = percentageDiscount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -1726,7 +2029,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -1755,13 +2061,24 @@ private constructor( fun build(): PercentageDiscountAdjustment = PercentageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - percentageDiscount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1892,16 +2209,16 @@ private constructor( */ fun usageDiscount(): Double = usageDiscount.getRequired("usage_discount") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -1909,21 +2226,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** * The number of usage units by which to discount the price this adjustment applies * to in a given billing period. */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -1953,20 +2272,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountAdjustment: UsageDiscountAdjustment) = apply { id = usageDiscountAdjustment.id adjustmentType = usageDiscountAdjustment.adjustmentType - appliesToPriceIds = usageDiscountAdjustment.appliesToPriceIds + appliesToPriceIds = + usageDiscountAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = usageDiscountAdjustment.isInvoiceLevel planPhaseOrder = usageDiscountAdjustment.planPhaseOrder reason = usageDiscountAdjustment.reason @@ -1992,7 +2312,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2010,9 +2344,18 @@ private constructor( this.isInvoiceLevel = isInvoiceLevel } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2020,7 +2363,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2064,13 +2410,24 @@ private constructor( fun build(): UsageDiscountAdjustment = UsageDiscountAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - planPhaseOrder, - reason, - usageDiscount, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -2207,16 +2564,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2224,24 +2581,26 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** The item ID that revenue from this minimum will be attributed to. */ - @JsonProperty("item_id") @ExcludeMissing fun _itemId() = itemId + @JsonProperty("item_id") @ExcludeMissing fun _itemId(): JsonField = itemId /** * The minimum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2272,21 +2631,22 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var itemId: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var itemId: JsonField? = null + private var minimumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumAdjustment: MinimumAdjustment) = apply { id = minimumAdjustment.id adjustmentType = minimumAdjustment.adjustmentType - appliesToPriceIds = minimumAdjustment.appliesToPriceIds + appliesToPriceIds = + minimumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = minimumAdjustment.isInvoiceLevel itemId = minimumAdjustment.itemId minimumAmount = minimumAdjustment.minimumAmount @@ -2312,7 +2672,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2351,9 +2725,18 @@ private constructor( this.minimumAmount = minimumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2361,7 +2744,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2390,14 +2776,25 @@ private constructor( fun build(): MinimumAdjustment = MinimumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - itemId, - minimumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(itemId) { "`itemId` is required but was not set" }, + checkNotNull(minimumAmount) { + "`minimumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2528,16 +2925,16 @@ private constructor( /** The reason for the adjustment. */ fun reason(): Optional = Optional.ofNullable(reason.getNullable("reason")) - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id @JsonProperty("adjustment_type") @ExcludeMissing - fun _adjustmentType() = adjustmentType + fun _adjustmentType(): JsonField = adjustmentType /** The price IDs that this adjustment applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** * True for adjustments that apply to an entire invocice, false for adjustments that @@ -2545,21 +2942,23 @@ private constructor( */ @JsonProperty("is_invoice_level") @ExcludeMissing - fun _isInvoiceLevel() = isInvoiceLevel + fun _isInvoiceLevel(): JsonField = isInvoiceLevel /** * The maximum amount to charge in a given billing period for the prices this * adjustment applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The plan phase in which this adjustment is active. */ @JsonProperty("plan_phase_order") @ExcludeMissing - fun _planPhaseOrder() = planPhaseOrder + fun _planPhaseOrder(): JsonField = planPhaseOrder /** The reason for the adjustment. */ - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason @JsonAnyGetter @ExcludeMissing @@ -2589,20 +2988,21 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var adjustmentType: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var isInvoiceLevel: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var planPhaseOrder: JsonField = JsonMissing.of() - private var reason: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var adjustmentType: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var isInvoiceLevel: JsonField? = null + private var maximumAmount: JsonField? = null + private var planPhaseOrder: JsonField? = null + private var reason: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumAdjustment: MaximumAdjustment) = apply { id = maximumAdjustment.id adjustmentType = maximumAdjustment.adjustmentType - appliesToPriceIds = maximumAdjustment.appliesToPriceIds + appliesToPriceIds = + maximumAdjustment.appliesToPriceIds.map { it.toMutableList() } isInvoiceLevel = maximumAdjustment.isInvoiceLevel maximumAmount = maximumAdjustment.maximumAmount planPhaseOrder = maximumAdjustment.planPhaseOrder @@ -2627,7 +3027,21 @@ private constructor( /** The price IDs that this adjustment applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price IDs that this adjustment applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** @@ -2660,9 +3074,18 @@ private constructor( this.maximumAmount = maximumAmount } + /** The plan phase in which this adjustment is active. */ + fun planPhaseOrder(planPhaseOrder: Long?) = + planPhaseOrder(JsonField.ofNullable(planPhaseOrder)) + /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: Long) = - planPhaseOrder(JsonField.of(planPhaseOrder)) + planPhaseOrder(planPhaseOrder as Long?) + + /** The plan phase in which this adjustment is active. */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun planPhaseOrder(planPhaseOrder: Optional) = + planPhaseOrder(planPhaseOrder.orElse(null) as Long?) /** The plan phase in which this adjustment is active. */ fun planPhaseOrder(planPhaseOrder: JsonField) = apply { @@ -2670,7 +3093,10 @@ private constructor( } /** The reason for the adjustment. */ - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + /** The reason for the adjustment. */ + fun reason(reason: Optional) = reason(reason.orElse(null)) /** The reason for the adjustment. */ fun reason(reason: JsonField) = apply { this.reason = reason } @@ -2699,13 +3125,24 @@ private constructor( fun build(): MaximumAdjustment = MaximumAdjustment( - id, - adjustmentType, - appliesToPriceIds.map { it.toImmutable() }, - isInvoiceLevel, - maximumAmount, - planPhaseOrder, - reason, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(adjustmentType) { + "`adjustmentType` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(isInvoiceLevel) { + "`isInvoiceLevel` is required but was not set" + }, + checkNotNull(maximumAmount) { + "`maximumAmount` is required but was not set" + }, + checkNotNull(planPhaseOrder) { + "`planPhaseOrder` is required but was not set" + }, + checkNotNull(reason) { "`reason` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -2838,19 +3275,19 @@ private constructor( * cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the * 30th. */ - @JsonProperty("day") @ExcludeMissing fun _day() = day + @JsonProperty("day") @ExcludeMissing fun _day(): JsonField = day /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - @JsonProperty("month") @ExcludeMissing fun _month() = month + @JsonProperty("month") @ExcludeMissing fun _month(): JsonField = month /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on * 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - @JsonProperty("year") @ExcludeMissing fun _year() = year + @JsonProperty("year") @ExcludeMissing fun _year(): JsonField = year @JsonAnyGetter @ExcludeMissing @@ -2876,7 +3313,7 @@ private constructor( class Builder { - private var day: JsonField = JsonMissing.of() + private var day: JsonField? = null private var month: JsonField = JsonMissing.of() private var year: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @@ -2911,7 +3348,20 @@ private constructor( * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in * February would have cycles starting February, May, August, and November). */ - fun month(month: Long) = month(JsonField.of(month)) + fun month(month: Long?) = month(JsonField.ofNullable(month)) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + fun month(month: Long) = month(month as Long?) + + /** + * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in + * February would have cycles starting February, May, August, and November). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun month(month: Optional) = month(month.orElse(null) as Long?) /** * The month on which the billing cycle is anchored (e.g. a quarterly price anchored in @@ -2923,7 +3373,20 @@ private constructor( * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). */ - fun year(year: Long) = year(JsonField.of(year)) + fun year(year: Long?) = year(JsonField.ofNullable(year)) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + fun year(year: Long) = year(year as Long?) + + /** + * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored + * on 2021 would have cycles starting on 2021, 2023, 2025, etc.). + */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun year(year: Optional) = year(year.orElse(null) as Long?) /** * The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored @@ -2952,7 +3415,7 @@ private constructor( fun build(): BillingCycleAnchorConfiguration = BillingCycleAnchorConfiguration( - day, + checkNotNull(day) { "`day` is required but was not set" }, month, year, additionalProperties.toImmutable(), @@ -3204,25 +3667,33 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") /** Only available if discount_type is `amount`. */ - @JsonProperty("amount_discount") @ExcludeMissing fun _amountDiscount() = amountDiscount + @JsonProperty("amount_discount") + @ExcludeMissing + fun _amountDiscount(): JsonField = amountDiscount /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3251,19 +3722,21 @@ private constructor( class Builder { - private var amountDiscount: JsonField = JsonMissing.of() - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var amountDiscount: JsonField? = null + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(amountDiscountInterval: AmountDiscountInterval) = apply { amountDiscount = amountDiscountInterval.amountDiscount - appliesToPriceIds = amountDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = amountDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + amountDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + amountDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = amountDiscountInterval.discountType endDate = amountDiscountInterval.endDate startDate = amountDiscountInterval.startDate @@ -3286,7 +3759,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3296,9 +3783,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3307,7 +3809,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3344,12 +3849,20 @@ private constructor( fun build(): AmountDiscountInterval = AmountDiscountInterval( - amountDiscount, - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, + checkNotNull(amountDiscount) { + "`amountDiscount` is required but was not set" + }, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3472,25 +3985,31 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** Only available if discount_type is `percentage`.This is a number between 0 and 1. */ @JsonProperty("percentage_discount") @ExcludeMissing - fun _percentageDiscount() = percentageDiscount + fun _percentageDiscount(): JsonField = percentageDiscount /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -3519,18 +4038,22 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var percentageDiscount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var percentageDiscount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(percentageDiscountInterval: PercentageDiscountInterval) = apply { - appliesToPriceIds = percentageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = percentageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + percentageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + percentageDiscountInterval.appliesToPriceIntervalIds.map { + it.toMutableList() + } discountType = percentageDiscountInterval.discountType endDate = percentageDiscountInterval.endDate percentageDiscount = percentageDiscountInterval.percentageDiscount @@ -3545,7 +4068,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3555,9 +4092,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3566,7 +4118,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3616,12 +4171,20 @@ private constructor( fun build(): PercentageDiscountInterval = PercentageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - percentageDiscount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(percentageDiscount) { + "`percentageDiscount` is required but was not set" + }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -3747,26 +4310,34 @@ private constructor( /** The price ids that this discount interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this discount interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType /** The end date of the discount interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** The start date of the discount interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate /** * Only available if discount_type is `usage`. Number of usage units that this discount * is for */ - @JsonProperty("usage_discount") @ExcludeMissing fun _usageDiscount() = usageDiscount + @JsonProperty("usage_discount") + @ExcludeMissing + fun _usageDiscount(): JsonField = usageDiscount @JsonAnyGetter @ExcludeMissing @@ -3795,18 +4366,20 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() - private var usageDiscount: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var discountType: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null + private var usageDiscount: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(usageDiscountInterval: UsageDiscountInterval) = apply { - appliesToPriceIds = usageDiscountInterval.appliesToPriceIds - appliesToPriceIntervalIds = usageDiscountInterval.appliesToPriceIntervalIds + appliesToPriceIds = + usageDiscountInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + usageDiscountInterval.appliesToPriceIntervalIds.map { it.toMutableList() } discountType = usageDiscountInterval.discountType endDate = usageDiscountInterval.endDate startDate = usageDiscountInterval.startDate @@ -3820,7 +4393,21 @@ private constructor( /** The price ids that this discount interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this discount interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this discount interval applies to. */ @@ -3830,9 +4417,24 @@ private constructor( /** The price interval ids that this discount interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this discount interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -3841,7 +4443,10 @@ private constructor( } /** The end date of the discount interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** The end date of the discount interval. */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the discount interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -3893,12 +4498,20 @@ private constructor( fun build(): UsageDiscountInterval = UsageDiscountInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - discountType, - endDate, - startDate, - usageDiscount, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, + checkNotNull(usageDiscount) { + "`usageDiscount` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -4002,13 +4615,17 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4035,10 +4652,10 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -4050,7 +4667,9 @@ private constructor( additionalProperties = fixedFeeQuantitySchedule.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4089,10 +4708,10 @@ private constructor( fun build(): FixedFeeQuantitySchedule = FixedFeeQuantitySchedule( - endDate, - priceId, - quantity, - startDate, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4162,24 +4781,30 @@ private constructor( /** The price ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this maximum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the maximum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The maximum amount to charge in a given billing period for the price intervals this * transform applies to. */ - @JsonProperty("maximum_amount") @ExcludeMissing fun _maximumAmount() = maximumAmount + @JsonProperty("maximum_amount") + @ExcludeMissing + fun _maximumAmount(): JsonField = maximumAmount /** The start date of the maximum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4207,17 +4832,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var maximumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var maximumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(maximumInterval: MaximumInterval) = apply { - appliesToPriceIds = maximumInterval.appliesToPriceIds - appliesToPriceIntervalIds = maximumInterval.appliesToPriceIntervalIds + appliesToPriceIds = maximumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + maximumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = maximumInterval.endDate maximumAmount = maximumInterval.maximumAmount startDate = maximumInterval.startDate @@ -4230,7 +4856,21 @@ private constructor( /** The price ids that this maximum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this maximum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this maximum interval applies to. */ @@ -4240,11 +4880,29 @@ private constructor( /** The price interval ids that this maximum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this maximum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the maximum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the maximum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the maximum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4292,11 +4950,17 @@ private constructor( fun build(): MaximumInterval = MaximumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - maximumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(maximumAmount) { "`maximumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4446,24 +5110,30 @@ private constructor( /** The price ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds /** The price interval ids that this minimum interval applies to. */ @JsonProperty("applies_to_price_interval_ids") @ExcludeMissing - fun _appliesToPriceIntervalIds() = appliesToPriceIntervalIds + fun _appliesToPriceIntervalIds(): JsonField> = appliesToPriceIntervalIds /** The end date of the minimum interval. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The minimum amount to charge in a given billing period for the price intervals this * minimum applies to. */ - @JsonProperty("minimum_amount") @ExcludeMissing fun _minimumAmount() = minimumAmount + @JsonProperty("minimum_amount") + @ExcludeMissing + fun _minimumAmount(): JsonField = minimumAmount /** The start date of the minimum interval. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -4491,17 +5161,18 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var appliesToPriceIntervalIds: JsonField> = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var minimumAmount: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var appliesToPriceIntervalIds: JsonField>? = null + private var endDate: JsonField? = null + private var minimumAmount: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(minimumInterval: MinimumInterval) = apply { - appliesToPriceIds = minimumInterval.appliesToPriceIds - appliesToPriceIntervalIds = minimumInterval.appliesToPriceIntervalIds + appliesToPriceIds = minimumInterval.appliesToPriceIds.map { it.toMutableList() } + appliesToPriceIntervalIds = + minimumInterval.appliesToPriceIntervalIds.map { it.toMutableList() } endDate = minimumInterval.endDate minimumAmount = minimumInterval.minimumAmount startDate = minimumInterval.startDate @@ -4514,7 +5185,21 @@ private constructor( /** The price ids that this minimum interval applies to. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** The price ids that this minimum interval applies to. */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } /** The price interval ids that this minimum interval applies to. */ @@ -4524,11 +5209,29 @@ private constructor( /** The price interval ids that this minimum interval applies to. */ fun appliesToPriceIntervalIds(appliesToPriceIntervalIds: JsonField>) = apply { - this.appliesToPriceIntervalIds = appliesToPriceIntervalIds + this.appliesToPriceIntervalIds = + appliesToPriceIntervalIds.map { it.toMutableList() } } + /** The price interval ids that this minimum interval applies to. */ + fun addAppliesToPriceIntervalId(appliesToPriceIntervalId: String) = apply { + appliesToPriceIntervalIds = + (appliesToPriceIntervalIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceIntervalId) + } + } + + /** The end date of the minimum interval. */ + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + /** The end date of the minimum interval. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** The end date of the minimum interval. */ fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -4576,11 +5279,17 @@ private constructor( fun build(): MinimumInterval = MinimumInterval( - appliesToPriceIds.map { it.toImmutable() }, - appliesToPriceIntervalIds.map { it.toImmutable() }, - endDate, - minimumAmount, - startDate, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(appliesToPriceIntervalIds) { + "`appliesToPriceIntervalIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(minimumAmount) { "`minimumAmount` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -4915,10 +5624,12 @@ private constructor( */ fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id /** The day of the month that Orb bills for this price */ - @JsonProperty("billing_cycle_day") @ExcludeMissing fun _billingCycleDay() = billingCycleDay + @JsonProperty("billing_cycle_day") + @ExcludeMissing + fun _billingCycleDay(): JsonField = billingCycleDay /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -4927,7 +5638,7 @@ private constructor( */ @JsonProperty("current_billing_period_end_date") @ExcludeMissing - fun _currentBillingPeriodEndDate() = currentBillingPeriodEndDate + fun _currentBillingPeriodEndDate(): JsonField = currentBillingPeriodEndDate /** * The start date of the current billing period. This is an inclusive timestamp; the instant @@ -4936,13 +5647,16 @@ private constructor( */ @JsonProperty("current_billing_period_start_date") @ExcludeMissing - fun _currentBillingPeriodStartDate() = currentBillingPeriodStartDate + fun _currentBillingPeriodStartDate(): JsonField = + currentBillingPeriodStartDate /** * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -4950,7 +5664,8 @@ private constructor( */ @JsonProperty("fixed_fee_quantity_transitions") @ExcludeMissing - fun _fixedFeeQuantityTransitions() = fixedFeeQuantityTransitions + fun _fixedFeeQuantityTransitions(): JsonField> = + fixedFeeQuantityTransitions /** * The Price resource represents a price that can be billed on a subscription, resulting in @@ -5180,13 +5895,15 @@ private constructor( * } * ``` */ - @JsonProperty("price") @ExcludeMissing fun _price() = price + @JsonProperty("price") @ExcludeMissing fun _price(): JsonField = price /** * The start date of the price interval. This is the date that Orb starts billing for this * price. */ - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -5217,15 +5934,16 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var billingCycleDay: JsonField = JsonMissing.of() - private var currentBillingPeriodEndDate: JsonField = JsonMissing.of() - private var currentBillingPeriodStartDate: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var fixedFeeQuantityTransitions: JsonField> = - JsonMissing.of() - private var price: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var billingCycleDay: JsonField? = null + private var currentBillingPeriodEndDate: JsonField? = null + private var currentBillingPeriodStartDate: JsonField? = null + private var endDate: JsonField? = null + private var fixedFeeQuantityTransitions: + JsonField>? = + null + private var price: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5235,7 +5953,8 @@ private constructor( currentBillingPeriodEndDate = priceInterval.currentBillingPeriodEndDate currentBillingPeriodStartDate = priceInterval.currentBillingPeriodStartDate endDate = priceInterval.endDate - fixedFeeQuantityTransitions = priceInterval.fixedFeeQuantityTransitions + fixedFeeQuantityTransitions = + priceInterval.fixedFeeQuantityTransitions.map { it.toMutableList() } price = priceInterval.price startDate = priceInterval.startDate additionalProperties = priceInterval.additionalProperties.toMutableMap() @@ -5259,8 +5978,16 @@ private constructor( * instant returned is exactly the end of the billing period. Set to null if this price * interval is not currently active. */ - fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime) = - currentBillingPeriodEndDate(JsonField.of(currentBillingPeriodEndDate)) + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: OffsetDateTime?) = + currentBillingPeriodEndDate(JsonField.ofNullable(currentBillingPeriodEndDate)) + + /** + * The end of the current billing period. This is an exclusive timestamp, such that the + * instant returned is exactly the end of the billing period. Set to null if this price + * interval is not currently active. + */ + fun currentBillingPeriodEndDate(currentBillingPeriodEndDate: Optional) = + currentBillingPeriodEndDate(currentBillingPeriodEndDate.orElse(null)) /** * The end of the current billing period. This is an exclusive timestamp, such that the @@ -5276,8 +6003,17 @@ private constructor( * instant returned is exactly the beginning of the billing period. Set to null if this * price interval is not currently active. */ - fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime) = - currentBillingPeriodStartDate(JsonField.of(currentBillingPeriodStartDate)) + fun currentBillingPeriodStartDate(currentBillingPeriodStartDate: OffsetDateTime?) = + currentBillingPeriodStartDate(JsonField.ofNullable(currentBillingPeriodStartDate)) + + /** + * The start date of the current billing period. This is an inclusive timestamp; the + * instant returned is exactly the beginning of the billing period. Set to null if this + * price interval is not currently active. + */ + fun currentBillingPeriodStartDate( + currentBillingPeriodStartDate: Optional + ) = currentBillingPeriodStartDate(currentBillingPeriodStartDate.orElse(null)) /** * The start date of the current billing period. This is an inclusive timestamp; the @@ -5292,7 +6028,13 @@ private constructor( * The end date of the price interval. This is the date that Orb stops billing for this * price. */ - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + /** + * The end date of the price interval. This is the date that Orb stops billing for this + * price. + */ + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) /** * The end date of the price interval. This is the date that Orb stops billing for this @@ -5305,8 +6047,16 @@ private constructor( * fixed fees. */ fun fixedFeeQuantityTransitions( - fixedFeeQuantityTransitions: List - ) = fixedFeeQuantityTransitions(JsonField.of(fixedFeeQuantityTransitions)) + fixedFeeQuantityTransitions: List? + ) = fixedFeeQuantityTransitions(JsonField.ofNullable(fixedFeeQuantityTransitions)) + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun fixedFeeQuantityTransitions( + fixedFeeQuantityTransitions: Optional> + ) = fixedFeeQuantityTransitions(fixedFeeQuantityTransitions.orElse(null)) /** * The fixed fee quantity transitions for this price interval. This is only relevant for @@ -5314,7 +6064,29 @@ private constructor( */ fun fixedFeeQuantityTransitions( fixedFeeQuantityTransitions: JsonField> - ) = apply { this.fixedFeeQuantityTransitions = fixedFeeQuantityTransitions } + ) = apply { + this.fixedFeeQuantityTransitions = + fixedFeeQuantityTransitions.map { it.toMutableList() } + } + + /** + * The fixed fee quantity transitions for this price interval. This is only relevant for + * fixed fees. + */ + fun addFixedFeeQuantityTransition( + fixedFeeQuantityTransition: FixedFeeQuantityTransition + ) = apply { + fixedFeeQuantityTransitions = + (fixedFeeQuantityTransitions ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(fixedFeeQuantityTransition) + } + } /** * The Price resource represents a price that can be billed on a subscription, resulting @@ -5776,6 +6548,71 @@ private constructor( */ fun price(price: JsonField) = apply { this.price = price } + fun price(unitPrice: Price.UnitPrice) = price(Price.ofUnitPrice(unitPrice)) + + fun price(packagePrice: Price.PackagePrice) = price(Price.ofPackagePrice(packagePrice)) + + fun price(matrixPrice: Price.MatrixPrice) = price(Price.ofMatrixPrice(matrixPrice)) + + fun price(tieredPrice: Price.TieredPrice) = price(Price.ofTieredPrice(tieredPrice)) + + fun price(tieredBpsPrice: Price.TieredBpsPrice) = + price(Price.ofTieredBpsPrice(tieredBpsPrice)) + + fun price(bpsPrice: Price.BpsPrice) = price(Price.ofBpsPrice(bpsPrice)) + + fun price(bulkBpsPrice: Price.BulkBpsPrice) = price(Price.ofBulkBpsPrice(bulkBpsPrice)) + + fun price(bulkPrice: Price.BulkPrice) = price(Price.ofBulkPrice(bulkPrice)) + + fun price(thresholdTotalAmountPrice: Price.ThresholdTotalAmountPrice) = + price(Price.ofThresholdTotalAmountPrice(thresholdTotalAmountPrice)) + + fun price(tieredPackagePrice: Price.TieredPackagePrice) = + price(Price.ofTieredPackagePrice(tieredPackagePrice)) + + fun price(groupedTieredPrice: Price.GroupedTieredPrice) = + price(Price.ofGroupedTieredPrice(groupedTieredPrice)) + + fun price(tieredWithMinimumPrice: Price.TieredWithMinimumPrice) = + price(Price.ofTieredWithMinimumPrice(tieredWithMinimumPrice)) + + fun price(tieredPackageWithMinimumPrice: Price.TieredPackageWithMinimumPrice) = + price(Price.ofTieredPackageWithMinimumPrice(tieredPackageWithMinimumPrice)) + + fun price(packageWithAllocationPrice: Price.PackageWithAllocationPrice) = + price(Price.ofPackageWithAllocationPrice(packageWithAllocationPrice)) + + fun price(unitWithPercentPrice: Price.UnitWithPercentPrice) = + price(Price.ofUnitWithPercentPrice(unitWithPercentPrice)) + + fun price(matrixWithAllocationPrice: Price.MatrixWithAllocationPrice) = + price(Price.ofMatrixWithAllocationPrice(matrixWithAllocationPrice)) + + fun price(tieredWithProrationPrice: Price.TieredWithProrationPrice) = + price(Price.ofTieredWithProrationPrice(tieredWithProrationPrice)) + + fun price(unitWithProrationPrice: Price.UnitWithProrationPrice) = + price(Price.ofUnitWithProrationPrice(unitWithProrationPrice)) + + fun price(groupedAllocationPrice: Price.GroupedAllocationPrice) = + price(Price.ofGroupedAllocationPrice(groupedAllocationPrice)) + + fun price(groupedWithProratedMinimumPrice: Price.GroupedWithProratedMinimumPrice) = + price(Price.ofGroupedWithProratedMinimumPrice(groupedWithProratedMinimumPrice)) + + fun price(groupedWithMeteredMinimumPrice: Price.GroupedWithMeteredMinimumPrice) = + price(Price.ofGroupedWithMeteredMinimumPrice(groupedWithMeteredMinimumPrice)) + + fun price(matrixWithDisplayNamePrice: Price.MatrixWithDisplayNamePrice) = + price(Price.ofMatrixWithDisplayNamePrice(matrixWithDisplayNamePrice)) + + fun price(bulkWithProrationPrice: Price.BulkWithProrationPrice) = + price(Price.ofBulkWithProrationPrice(bulkWithProrationPrice)) + + fun price(groupedTieredPackagePrice: Price.GroupedTieredPackagePrice) = + price(Price.ofGroupedTieredPackagePrice(groupedTieredPackagePrice)) + /** * The start date of the price interval. This is the date that Orb starts billing for * this price. @@ -5811,14 +6648,23 @@ private constructor( fun build(): PriceInterval = PriceInterval( - id, - billingCycleDay, - currentBillingPeriodEndDate, - currentBillingPeriodStartDate, - endDate, - fixedFeeQuantityTransitions.map { it.toImmutable() }, - price, - startDate, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(billingCycleDay) { + "`billingCycleDay` is required but was not set" + }, + checkNotNull(currentBillingPeriodEndDate) { + "`currentBillingPeriodEndDate` is required but was not set" + }, + checkNotNull(currentBillingPeriodStartDate) { + "`currentBillingPeriodStartDate` is required but was not set" + }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(fixedFeeQuantityTransitions) { + "`fixedFeeQuantityTransitions` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(price) { "`price` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5846,11 +6692,13 @@ private constructor( fun quantity(): Long = quantity.getRequired("quantity") - @JsonProperty("effective_date") @ExcludeMissing fun _effectiveDate() = effectiveDate + @JsonProperty("effective_date") + @ExcludeMissing + fun _effectiveDate(): JsonField = effectiveDate - @JsonProperty("price_id") @ExcludeMissing fun _priceId() = priceId + @JsonProperty("price_id") @ExcludeMissing fun _priceId(): JsonField = priceId - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") @ExcludeMissing fun _quantity(): JsonField = quantity @JsonAnyGetter @ExcludeMissing @@ -5876,9 +6724,9 @@ private constructor( class Builder { - private var effectiveDate: JsonField = JsonMissing.of() - private var priceId: JsonField = JsonMissing.of() - private var quantity: JsonField = JsonMissing.of() + private var effectiveDate: JsonField? = null + private var priceId: JsonField? = null + private var quantity: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -5929,9 +6777,11 @@ private constructor( fun build(): FixedFeeQuantityTransition = FixedFeeQuantityTransition( - effectiveDate, - priceId, - quantity, + checkNotNull(effectiveDate) { + "`effectiveDate` is required but was not set" + }, + checkNotNull(priceId) { "`priceId` is required but was not set" }, + checkNotNull(quantity) { "`quantity` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -5996,11 +6846,15 @@ private constructor( fun startDate(): OffsetDateTime = startDate.getRequired("start_date") - @JsonProperty("coupon_id") @ExcludeMissing fun _couponId() = couponId + @JsonProperty("coupon_id") @ExcludeMissing fun _couponId(): JsonField = couponId - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate - @JsonProperty("start_date") @ExcludeMissing fun _startDate() = startDate + @JsonProperty("start_date") + @ExcludeMissing + fun _startDate(): JsonField = startDate @JsonAnyGetter @ExcludeMissing @@ -6026,9 +6880,9 @@ private constructor( class Builder { - private var couponId: JsonField = JsonMissing.of() - private var endDate: JsonField = JsonMissing.of() - private var startDate: JsonField = JsonMissing.of() + private var couponId: JsonField? = null + private var endDate: JsonField? = null + private var startDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6043,7 +6897,9 @@ private constructor( fun couponId(couponId: JsonField) = apply { this.couponId = couponId } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6074,9 +6930,9 @@ private constructor( fun build(): RedeemedCoupon = RedeemedCoupon( - couponId, - endDate, - startDate, + checkNotNull(couponId) { "`couponId` is required but was not set" }, + checkNotNull(endDate) { "`endDate` is required but was not set" }, + checkNotNull(startDate) { "`startDate` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -6176,7 +7032,9 @@ private constructor( fun endDate(): Optional = Optional.ofNullable(endDate.getNullable("end_date")) - @JsonProperty("end_date") @ExcludeMissing fun _endDate() = endDate + @JsonProperty("end_date") + @ExcludeMissing + fun _endDate(): JsonField = endDate @JsonAnyGetter @ExcludeMissing @@ -6200,7 +7058,7 @@ private constructor( class Builder { - private var endDate: JsonField = JsonMissing.of() + private var endDate: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -6209,7 +7067,9 @@ private constructor( additionalProperties = trialInfo.additionalProperties.toMutableMap() } - fun endDate(endDate: OffsetDateTime) = endDate(JsonField.of(endDate)) + fun endDate(endDate: OffsetDateTime?) = endDate(JsonField.ofNullable(endDate)) + + fun endDate(endDate: Optional) = endDate(endDate.orElse(null)) fun endDate(endDate: JsonField) = apply { this.endDate = endDate } @@ -6232,7 +7092,11 @@ private constructor( keys.forEach(::removeAdditionalProperty) } - fun build(): TrialInfo = TrialInfo(endDate, additionalProperties.toImmutable()) + fun build(): TrialInfo = + TrialInfo( + checkNotNull(endDate) { "`endDate` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt index cb06cf04..4a496dc0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/SubscriptionUsage.kt @@ -172,7 +172,7 @@ private constructor( fun data(): List = data.getRequired("data") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonAnyGetter @ExcludeMissing @@ -196,19 +196,34 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(ungroupedSubscriptionUsage: UngroupedSubscriptionUsage) = apply { - data = ungroupedSubscriptionUsage.data + data = ungroupedSubscriptionUsage.data.map { it.toMutableList() } additionalProperties = ungroupedSubscriptionUsage.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun additionalProperties(additionalProperties: Map) = apply { this.additionalProperties.clear() @@ -231,7 +246,8 @@ private constructor( fun build(): UngroupedSubscriptionUsage = UngroupedSubscriptionUsage( - data.map { it.toImmutable() }, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, additionalProperties.toImmutable() ) } @@ -259,11 +275,15 @@ private constructor( fun viewMode(): ViewMode = viewMode.getRequired("view_mode") - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - @JsonProperty("usage") @ExcludeMissing fun _usage() = usage + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField> = usage - @JsonProperty("view_mode") @ExcludeMissing fun _viewMode() = viewMode + @JsonProperty("view_mode") + @ExcludeMissing + fun _viewMode(): JsonField = viewMode @JsonAnyGetter @ExcludeMissing @@ -289,15 +309,15 @@ private constructor( class Builder { - private var billableMetric: JsonField = JsonMissing.of() - private var usage: JsonField> = JsonMissing.of() - private var viewMode: JsonField = JsonMissing.of() + private var billableMetric: JsonField? = null + private var usage: JsonField>? = null + private var viewMode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { billableMetric = data.billableMetric - usage = data.usage + usage = data.usage.map { it.toMutableList() } viewMode = data.viewMode additionalProperties = data.additionalProperties.toMutableMap() } @@ -311,7 +331,22 @@ private constructor( fun usage(usage: List) = usage(JsonField.of(usage)) - fun usage(usage: JsonField>) = apply { this.usage = usage } + fun usage(usage: JsonField>) = apply { + this.usage = usage.map { it.toMutableList() } + } + + fun addUsage(usage: Usage) = apply { + this.usage = + (this.usage ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(usage) + } + } fun viewMode(viewMode: ViewMode) = viewMode(JsonField.of(viewMode)) @@ -341,9 +376,12 @@ private constructor( fun build(): Data = Data( - billableMetric, - usage.map { it.toImmutable() }, - viewMode, + checkNotNull(billableMetric) { + "`billableMetric` is required but was not set" + }, + checkNotNull(usage) { "`usage` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(viewMode) { "`viewMode` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -366,9 +404,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -393,8 +431,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -436,8 +474,8 @@ private constructor( fun build(): BillableMetric = BillableMetric( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -483,13 +521,17 @@ private constructor( fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd @JsonProperty("timeframe_start") @ExcludeMissing - fun _timeframeStart() = timeframeStart + fun _timeframeStart(): JsonField = timeframeStart @JsonAnyGetter @ExcludeMissing @@ -515,9 +557,9 @@ private constructor( class Builder { - private var quantity: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var quantity: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -570,9 +612,13 @@ private constructor( fun build(): Usage = Usage( - quantity, - timeframeEnd, - timeframeStart, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(timeframeEnd) { + "`timeframeEnd` is required but was not set" + }, + checkNotNull(timeframeStart) { + "`timeframeStart` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -707,11 +753,11 @@ private constructor( fun paginationMetadata(): Optional = Optional.ofNullable(paginationMetadata.getNullable("pagination_metadata")) - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonProperty("pagination_metadata") @ExcludeMissing - fun _paginationMetadata() = paginationMetadata + fun _paginationMetadata(): JsonField = paginationMetadata @JsonAnyGetter @ExcludeMissing @@ -736,23 +782,41 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() + private var data: JsonField>? = null private var paginationMetadata: JsonField = JsonMissing.of() private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(groupedSubscriptionUsage: GroupedSubscriptionUsage) = apply { - data = groupedSubscriptionUsage.data + data = groupedSubscriptionUsage.data.map { it.toMutableList() } paginationMetadata = groupedSubscriptionUsage.paginationMetadata additionalProperties = groupedSubscriptionUsage.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Data) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } - fun paginationMetadata(paginationMetadata: PaginationMetadata) = - paginationMetadata(JsonField.of(paginationMetadata)) + fun paginationMetadata(paginationMetadata: PaginationMetadata?) = + paginationMetadata(JsonField.ofNullable(paginationMetadata)) + + fun paginationMetadata(paginationMetadata: Optional) = + paginationMetadata(paginationMetadata.orElse(null)) fun paginationMetadata(paginationMetadata: JsonField) = apply { this.paginationMetadata = paginationMetadata @@ -779,7 +843,8 @@ private constructor( fun build(): GroupedSubscriptionUsage = GroupedSubscriptionUsage( - data.map { it.toImmutable() }, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, paginationMetadata, additionalProperties.toImmutable(), ) @@ -813,13 +878,19 @@ private constructor( fun viewMode(): ViewMode = viewMode.getRequired("view_mode") - @JsonProperty("billable_metric") @ExcludeMissing fun _billableMetric() = billableMetric + @JsonProperty("billable_metric") + @ExcludeMissing + fun _billableMetric(): JsonField = billableMetric - @JsonProperty("metric_group") @ExcludeMissing fun _metricGroup() = metricGroup + @JsonProperty("metric_group") + @ExcludeMissing + fun _metricGroup(): JsonField = metricGroup - @JsonProperty("usage") @ExcludeMissing fun _usage() = usage + @JsonProperty("usage") @ExcludeMissing fun _usage(): JsonField> = usage - @JsonProperty("view_mode") @ExcludeMissing fun _viewMode() = viewMode + @JsonProperty("view_mode") + @ExcludeMissing + fun _viewMode(): JsonField = viewMode @JsonAnyGetter @ExcludeMissing @@ -846,17 +917,17 @@ private constructor( class Builder { - private var billableMetric: JsonField = JsonMissing.of() - private var metricGroup: JsonField = JsonMissing.of() - private var usage: JsonField> = JsonMissing.of() - private var viewMode: JsonField = JsonMissing.of() + private var billableMetric: JsonField? = null + private var metricGroup: JsonField? = null + private var usage: JsonField>? = null + private var viewMode: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(data: Data) = apply { billableMetric = data.billableMetric metricGroup = data.metricGroup - usage = data.usage + usage = data.usage.map { it.toMutableList() } viewMode = data.viewMode additionalProperties = data.additionalProperties.toMutableMap() } @@ -876,7 +947,22 @@ private constructor( fun usage(usage: List) = usage(JsonField.of(usage)) - fun usage(usage: JsonField>) = apply { this.usage = usage } + fun usage(usage: JsonField>) = apply { + this.usage = usage.map { it.toMutableList() } + } + + fun addUsage(usage: Usage) = apply { + this.usage = + (this.usage ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(usage) + } + } fun viewMode(viewMode: ViewMode) = viewMode(JsonField.of(viewMode)) @@ -906,10 +992,13 @@ private constructor( fun build(): Data = Data( - billableMetric, - metricGroup, - usage.map { it.toImmutable() }, - viewMode, + checkNotNull(billableMetric) { + "`billableMetric` is required but was not set" + }, + checkNotNull(metricGroup) { "`metricGroup` is required but was not set" }, + checkNotNull(usage) { "`usage` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(viewMode) { "`viewMode` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -932,9 +1021,9 @@ private constructor( fun name(): String = name.getRequired("name") - @JsonProperty("id") @ExcludeMissing fun _id() = id + @JsonProperty("id") @ExcludeMissing fun _id(): JsonField = id - @JsonProperty("name") @ExcludeMissing fun _name() = name + @JsonProperty("name") @ExcludeMissing fun _name(): JsonField = name @JsonAnyGetter @ExcludeMissing @@ -959,8 +1048,8 @@ private constructor( class Builder { - private var id: JsonField = JsonMissing.of() - private var name: JsonField = JsonMissing.of() + private var id: JsonField? = null + private var name: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1002,8 +1091,8 @@ private constructor( fun build(): BillableMetric = BillableMetric( - id, - name, + checkNotNull(id) { "`id` is required but was not set" }, + checkNotNull(name) { "`name` is required but was not set" }, additionalProperties.toImmutable(), ) } @@ -1044,9 +1133,13 @@ private constructor( fun propertyValue(): String = propertyValue.getRequired("property_value") - @JsonProperty("property_key") @ExcludeMissing fun _propertyKey() = propertyKey + @JsonProperty("property_key") + @ExcludeMissing + fun _propertyKey(): JsonField = propertyKey - @JsonProperty("property_value") @ExcludeMissing fun _propertyValue() = propertyValue + @JsonProperty("property_value") + @ExcludeMissing + fun _propertyValue(): JsonField = propertyValue @JsonAnyGetter @ExcludeMissing @@ -1071,8 +1164,8 @@ private constructor( class Builder { - private var propertyKey: JsonField = JsonMissing.of() - private var propertyValue: JsonField = JsonMissing.of() + private var propertyKey: JsonField? = null + private var propertyValue: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1119,8 +1212,12 @@ private constructor( fun build(): MetricGroup = MetricGroup( - propertyKey, - propertyValue, + checkNotNull(propertyKey) { + "`propertyKey` is required but was not set" + }, + checkNotNull(propertyValue) { + "`propertyValue` is required but was not set" + }, additionalProperties.toImmutable(), ) } @@ -1166,13 +1263,17 @@ private constructor( fun timeframeStart(): OffsetDateTime = timeframeStart.getRequired("timeframe_start") - @JsonProperty("quantity") @ExcludeMissing fun _quantity() = quantity + @JsonProperty("quantity") + @ExcludeMissing + fun _quantity(): JsonField = quantity - @JsonProperty("timeframe_end") @ExcludeMissing fun _timeframeEnd() = timeframeEnd + @JsonProperty("timeframe_end") + @ExcludeMissing + fun _timeframeEnd(): JsonField = timeframeEnd @JsonProperty("timeframe_start") @ExcludeMissing - fun _timeframeStart() = timeframeStart + fun _timeframeStart(): JsonField = timeframeStart @JsonAnyGetter @ExcludeMissing @@ -1198,9 +1299,9 @@ private constructor( class Builder { - private var quantity: JsonField = JsonMissing.of() - private var timeframeEnd: JsonField = JsonMissing.of() - private var timeframeStart: JsonField = JsonMissing.of() + private var quantity: JsonField? = null + private var timeframeEnd: JsonField? = null + private var timeframeStart: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -1253,9 +1354,13 @@ private constructor( fun build(): Usage = Usage( - quantity, - timeframeEnd, - timeframeStart, + checkNotNull(quantity) { "`quantity` is required but was not set" }, + checkNotNull(timeframeEnd) { + "`timeframeEnd` is required but was not set" + }, + checkNotNull(timeframeStart) { + "`timeframeStart` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt index 2a3ee645..69e4c1b7 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/Subscriptions.kt @@ -33,11 +33,11 @@ private constructor( fun paginationMetadata(): PaginationMetadata = paginationMetadata.getRequired("pagination_metadata") - @JsonProperty("data") @ExcludeMissing fun _data() = data + @JsonProperty("data") @ExcludeMissing fun _data(): JsonField> = data @JsonProperty("pagination_metadata") @ExcludeMissing - fun _paginationMetadata() = paginationMetadata + fun _paginationMetadata(): JsonField = paginationMetadata @JsonAnyGetter @ExcludeMissing @@ -62,20 +62,35 @@ private constructor( class Builder { - private var data: JsonField> = JsonMissing.of() - private var paginationMetadata: JsonField = JsonMissing.of() + private var data: JsonField>? = null + private var paginationMetadata: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic internal fun from(subscriptions: Subscriptions) = apply { - data = subscriptions.data + data = subscriptions.data.map { it.toMutableList() } paginationMetadata = subscriptions.paginationMetadata additionalProperties = subscriptions.additionalProperties.toMutableMap() } fun data(data: List) = data(JsonField.of(data)) - fun data(data: JsonField>) = apply { this.data = data } + fun data(data: JsonField>) = apply { + this.data = data.map { it.toMutableList() } + } + + fun addData(data: Subscription) = apply { + this.data = + (this.data ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(data) + } + } fun paginationMetadata(paginationMetadata: PaginationMetadata) = paginationMetadata(JsonField.of(paginationMetadata)) @@ -105,8 +120,11 @@ private constructor( fun build(): Subscriptions = Subscriptions( - data.map { it.toImmutable() }, - paginationMetadata, + checkNotNull(data) { "`data` is required but was not set" } + .map { it.toImmutable() }, + checkNotNull(paginationMetadata) { + "`paginationMetadata` is required but was not set" + }, additionalProperties.toImmutable(), ) } diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt index 1ec61824..958b0db0 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingParams.kt @@ -7,6 +7,13 @@ import com.withorb.api.core.http.Headers import com.withorb.api.core.http.QueryParams import java.util.Objects +/** + * This endpoint allows you to test your connection to the Orb API and check the validity of your + * API key, passed in the Authorization header. This is particularly useful for checking that your + * environment is set up properly, and is a great choice for connectors and integrations. + * + * This API does not have any side-effects or return any Orb resources. + */ class TopLevelPingParams constructor( private val additionalHeaders: Headers, diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt index b02f1abc..58a7dd76 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TopLevelPingResponse.kt @@ -27,7 +27,7 @@ private constructor( fun response(): String = response.getRequired("response") - @JsonProperty("response") @ExcludeMissing fun _response() = response + @JsonProperty("response") @ExcludeMissing fun _response(): JsonField = response @JsonAnyGetter @ExcludeMissing @@ -51,7 +51,7 @@ private constructor( class Builder { - private var response: JsonField = JsonMissing.of() + private var response: JsonField? = null private var additionalProperties: MutableMap = mutableMapOf() @JvmSynthetic @@ -84,7 +84,10 @@ private constructor( } fun build(): TopLevelPingResponse = - TopLevelPingResponse(response, additionalProperties.toImmutable()) + TopLevelPingResponse( + checkNotNull(response) { "`response` is required but was not set" }, + additionalProperties.toImmutable() + ) } override fun equals(other: Any?): Boolean { diff --git a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt index b3d2a3cd..4e7023af 100644 --- a/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt +++ b/orb-java-core/src/main/kotlin/com/withorb/api/models/TrialDiscount.kt @@ -64,21 +64,23 @@ private constructor( */ @JsonProperty("applies_to_price_ids") @ExcludeMissing - fun _appliesToPriceIds() = appliesToPriceIds + fun _appliesToPriceIds(): JsonField> = appliesToPriceIds - @JsonProperty("discount_type") @ExcludeMissing fun _discountType() = discountType + @JsonProperty("discount_type") + @ExcludeMissing + fun _discountType(): JsonField = discountType - @JsonProperty("reason") @ExcludeMissing fun _reason() = reason + @JsonProperty("reason") @ExcludeMissing fun _reason(): JsonField = reason /** Only available if discount_type is `trial` */ @JsonProperty("trial_amount_discount") @ExcludeMissing - fun _trialAmountDiscount() = trialAmountDiscount + fun _trialAmountDiscount(): JsonField = trialAmountDiscount /** Only available if discount_type is `trial` */ @JsonProperty("trial_percentage_discount") @ExcludeMissing - fun _trialPercentageDiscount() = trialPercentageDiscount + fun _trialPercentageDiscount(): JsonField = trialPercentageDiscount @JsonAnyGetter @ExcludeMissing @@ -106,8 +108,8 @@ private constructor( class Builder { - private var appliesToPriceIds: JsonField> = JsonMissing.of() - private var discountType: JsonField = JsonMissing.of() + private var appliesToPriceIds: JsonField>? = null + private var discountType: JsonField? = null private var reason: JsonField = JsonMissing.of() private var trialAmountDiscount: JsonField = JsonMissing.of() private var trialPercentageDiscount: JsonField = JsonMissing.of() @@ -115,7 +117,7 @@ private constructor( @JvmSynthetic internal fun from(trialDiscount: TrialDiscount) = apply { - appliesToPriceIds = trialDiscount.appliesToPriceIds + appliesToPriceIds = trialDiscount.appliesToPriceIds.map { it.toMutableList() } discountType = trialDiscount.discountType reason = trialDiscount.reason trialAmountDiscount = trialDiscount.trialAmountDiscount @@ -135,7 +137,24 @@ private constructor( * be a subset of prices. */ fun appliesToPriceIds(appliesToPriceIds: JsonField>) = apply { - this.appliesToPriceIds = appliesToPriceIds + this.appliesToPriceIds = appliesToPriceIds.map { it.toMutableList() } + } + + /** + * List of price_ids that this discount applies to. For plan/plan phase discounts, this can + * be a subset of prices. + */ + fun addAppliesToPriceId(appliesToPriceId: String) = apply { + appliesToPriceIds = + (appliesToPriceIds ?: JsonField.of(mutableListOf())).apply { + asKnown() + .orElseThrow { + IllegalStateException( + "Field was set to non-list type: ${javaClass.simpleName}" + ) + } + .add(appliesToPriceId) + } } fun discountType(discountType: DiscountType) = discountType(JsonField.of(discountType)) @@ -144,22 +163,37 @@ private constructor( this.discountType = discountType } - fun reason(reason: String) = reason(JsonField.of(reason)) + fun reason(reason: String?) = reason(JsonField.ofNullable(reason)) + + fun reason(reason: Optional) = reason(reason.orElse(null)) fun reason(reason: JsonField) = apply { this.reason = reason } /** Only available if discount_type is `trial` */ - fun trialAmountDiscount(trialAmountDiscount: String) = - trialAmountDiscount(JsonField.of(trialAmountDiscount)) + fun trialAmountDiscount(trialAmountDiscount: String?) = + trialAmountDiscount(JsonField.ofNullable(trialAmountDiscount)) + + /** Only available if discount_type is `trial` */ + fun trialAmountDiscount(trialAmountDiscount: Optional) = + trialAmountDiscount(trialAmountDiscount.orElse(null)) /** Only available if discount_type is `trial` */ fun trialAmountDiscount(trialAmountDiscount: JsonField) = apply { this.trialAmountDiscount = trialAmountDiscount } + /** Only available if discount_type is `trial` */ + fun trialPercentageDiscount(trialPercentageDiscount: Double?) = + trialPercentageDiscount(JsonField.ofNullable(trialPercentageDiscount)) + /** Only available if discount_type is `trial` */ fun trialPercentageDiscount(trialPercentageDiscount: Double) = - trialPercentageDiscount(JsonField.of(trialPercentageDiscount)) + trialPercentageDiscount(trialPercentageDiscount as Double?) + + /** Only available if discount_type is `trial` */ + @Suppress("USELESS_CAST") // See https://youtrack.jetbrains.com/issue/KT-74228 + fun trialPercentageDiscount(trialPercentageDiscount: Optional) = + trialPercentageDiscount(trialPercentageDiscount.orElse(null) as Double?) /** Only available if discount_type is `trial` */ fun trialPercentageDiscount(trialPercentageDiscount: JsonField) = apply { @@ -187,8 +221,11 @@ private constructor( fun build(): TrialDiscount = TrialDiscount( - appliesToPriceIds.map { it.toImmutable() }, - discountType, + checkNotNull(appliesToPriceIds) { + "`appliesToPriceIds` is required but was not set" + } + .map { it.toImmutable() }, + checkNotNull(discountType) { "`discountType` is required but was not set" }, reason, trialAmountDiscount, trialPercentageDiscount, diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateParamsTest.kt index 0108244c..5883b628 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/EventUpdateParamsTest.kt @@ -35,7 +35,7 @@ class EventUpdateParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.eventName()).isEqualTo("event_name") - assertThat(body.properties()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body._properties()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.timestamp()).isEqualTo(OffsetDateTime.parse("2020-12-09T16:09:53Z")) assertThat(body.customerId()).contains("customer_id") assertThat(body.externalCustomerId()).contains("external_customer_id") @@ -53,7 +53,7 @@ class EventUpdateParamsTest { val body = params.getBody() assertThat(body).isNotNull assertThat(body.eventName()).isEqualTo("event_name") - assertThat(body.properties()).isEqualTo(JsonValue.from(mapOf())) + assertThat(body._properties()).isEqualTo(JsonValue.from(mapOf())) assertThat(body.timestamp()).isEqualTo(OffsetDateTime.parse("2020-12-09T16:09:53Z")) } diff --git a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricCreateParamsTest.kt b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricCreateParamsTest.kt index afe703c9..92fe23db 100644 --- a/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricCreateParamsTest.kt +++ b/orb-java-core/src/test/kotlin/com/withorb/api/models/MetricCreateParamsTest.kt @@ -56,12 +56,14 @@ class MetricCreateParamsTest { fun getBodyWithoutOptionalFields() { val params = MetricCreateParams.builder() + .description("Sum of bytes downloaded in fast mode") .itemId("item_id") .name("Bytes downloaded") .sql("SELECT sum(bytes_downloaded) FROM events WHERE download_speed = 'fast'") .build() val body = params.getBody() assertThat(body).isNotNull + assertThat(body.description()).contains("Sum of bytes downloaded in fast mode") assertThat(body.itemId()).isEqualTo("item_id") assertThat(body.name()).isEqualTo("Bytes downloaded") assertThat(body.sql())